@forsion/unit 2.13.5 → 2.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +2 -2
  2. package/main.mjs +20 -4
  3. package/package.json +1 -1
  4. package/release.json +6 -5
  5. package/web/assets/{ArtificialView-BD1yHz1N.js → ArtificialView-DHqb9CTL.js} +1 -1
  6. package/web/assets/{AutomationBuilder-B09c-5Bi.js → AutomationBuilder-CzBKmOiw.js} +1 -1
  7. package/web/assets/{CalendarConfigView-Bd-ZDGPO.js → CalendarConfigView-Blw47NCs.js} +1 -1
  8. package/web/assets/CalendarSide-CFSzme3H.js +1 -0
  9. package/web/assets/CalendarView-B8sQfgZt.js +3 -0
  10. package/web/assets/{CapabilityMenu-DyHTEYLr.js → CapabilityMenu-Dzn6RbB1.js} +1 -1
  11. package/web/assets/{Chrome-C7F6fdDp.js → Chrome-owLewFu4.js} +1 -1
  12. package/web/assets/{CodeView-BGOnrGhB.js → CodeView-E18NDilX.js} +3 -3
  13. package/web/assets/{CtxMenuButtons-BYjrbUKS.js → CtxMenuButtons-CAiwQkOK.js} +1 -1
  14. package/web/assets/DashboardGridView-CBbYKcCo.js +25 -0
  15. package/web/assets/EventCard-D9uQe7g4.js +1 -0
  16. package/web/assets/{ExcalidrawCanvas-lwJCN6uB.js → ExcalidrawCanvas-BSOERegJ.js} +1 -1
  17. package/web/assets/{FloatingToc-DO7SH8Ku.js → FloatingToc-iK08Qpjc.js} +1 -1
  18. package/web/assets/GitCloneDialog-DfY0kqhP.js +1 -0
  19. package/web/assets/{HomepageView-CHJEhf9c.js → HomepageView-BCqFe1Ym.js} +3 -3
  20. package/web/assets/{ImageStudioPanels-CgVf0wiq.js → ImageStudioPanels-DdwihAkT.js} +2 -2
  21. package/web/assets/ImageStudioView-gJSYrmu1.js +1 -0
  22. package/web/assets/{InlineAiPanel-CdIPINsA.js → InlineAiPanel-CjYOW0_0.js} +1 -1
  23. package/web/assets/InlineFiles-3g2jMUeA.js +1 -0
  24. package/web/assets/{MarkdownBlock-DSItkLhu.js → MarkdownBlock-DjsGkPZ_.js} +24 -24
  25. package/web/assets/{ModelPill--CU3XTIQ.js → ModelPill-DgyXBsL9.js} +2 -2
  26. package/web/assets/MuseLibraryView-D_HBijmU.js +2 -0
  27. package/web/assets/{MuseView-CvsO62Fo.js → MuseView-BVDlmM6i.js} +3 -3
  28. package/web/assets/{PageHistoryPanel-CDh7nm78.js → PageHistoryPanel-B1EAPZeX.js} +2 -2
  29. package/web/assets/{PdfAnnotator-DafvjP3U.js → PdfAnnotator-bdB9evsY.js} +1 -1
  30. package/web/assets/{PenRow-CEy-s6SF.js → PenRow-DCOIGlfY.js} +1 -1
  31. package/web/assets/PluginToolCard-BXE5vA1h.js +2 -0
  32. package/web/assets/{ProductView-AUqnTwmQ.js → ProductView-l5Q7uBy6.js} +1 -1
  33. package/web/assets/{SettingsPage-B9mmkWaM.js → SettingsPage-fjxfS_Mt.js} +2 -2
  34. package/web/assets/{StudioGuestSurface-OOhRA8nt.js → StudioGuestSurface-360CWUwf.js} +1 -1
  35. package/web/assets/TodoListView-BsPt2GUU.js +1 -0
  36. package/web/assets/{Tooltip-DOYi44eY.js → Tooltip-CuXpWtdJ.js} +1 -1
  37. package/web/assets/UnifiedPage-6xbFLtXT.js +712 -0
  38. package/web/assets/{ViewSelectionBar-WmSWMFsR.js → ViewSelectionBar-C5FDh7fO.js} +2 -2
  39. package/web/assets/{appStore-DDOkzWDA.js → appStore-BskcSDl6.js} +114 -115
  40. package/web/assets/{arrow-up-right-BptN64d-.js → arrow-up-right-DEykpgsH.js} +1 -1
  41. package/web/assets/{astryxBridge-BL56QfEv.js → astryxBridge-B2IZdPvo.js} +1 -1
  42. package/web/assets/automationListSource-Cm09JKkK.js +1 -0
  43. package/web/assets/{boardSurface-CP4HNmcm.js → boardSurface-Dv-aVaUJ.js} +1 -1
  44. package/web/assets/{calendarNavStore-DCi7VBmM.js → calendarNavStore-FKStA7Hh.js} +1 -1
  45. package/web/assets/{canvasPrefs-ArsX3NFO.js → canvasPrefs-CMulOS0k.js} +1 -1
  46. package/web/assets/{chatBoxSurface-DRsDr-MT.js → chatBoxSurface-BR_G6cxG.js} +1 -1
  47. package/web/assets/{chevron-up-ChXNh14u.js → chevron-up-C_EDOZzI.js} +1 -1
  48. package/web/assets/{client-fKy9CWk0.js → client-DD5czSuF.js} +1 -1
  49. package/web/assets/{code-xml-DCCD9eCS.js → code-xml-vTB4LtTf.js} +1 -1
  50. package/web/assets/{codeStudioStore-BgLfCDK2.js → codeStudioStore-OswE1_s0.js} +1 -1
  51. package/web/assets/{contextMenuSurface-BF593l2M.js → contextMenuSurface-DqdYEGuH.js} +1 -1
  52. package/web/assets/{copy-plus-ClKrSgM7.js → copy-plus-CVHqDNny.js} +1 -1
  53. package/web/assets/create-DZWy4zBR.js +14 -0
  54. package/web/assets/{dashboardSurface-C6cbR3oG.js → dashboardSurface-Co4byEQm.js} +1 -1
  55. package/web/assets/dbStore-Bc2lC8ZI.js +2 -0
  56. package/web/assets/deskCapture-BfTzH2aO.js +1 -0
  57. package/web/assets/{diff2html-Di8qIz6O.js → diff2html-0MkNy2ws.js} +1 -1
  58. package/web/assets/{docx-preview-B-URZXdP.js → docx-preview-CwNWZegI.js} +1 -1
  59. package/web/assets/{draft-CBSW5tHx.js → draft-DTzuTatQ.js} +2 -2
  60. package/web/assets/{drawingStore-CGvTqqYW.js → drawingStore-BD5m2eqn.js} +1 -1
  61. package/web/assets/{file-down-Z913cCyQ.js → file-down-Cjo_T6By.js} +1 -1
  62. package/web/assets/{floatingTocSurface-DGwTiqvU.js → floatingTocSurface-D3IIVNnq.js} +1 -1
  63. package/web/assets/{foldActions-DGIPTmE1.js → foldActions-utwZpRrA.js} +1 -1
  64. package/web/assets/{folder-1OJQeDI1.js → folder-DiaFWdCg.js} +1 -1
  65. package/web/assets/{folder-minus-D_j1SwHu.js → folder-minus-DUEOcs12.js} +1 -1
  66. package/web/assets/{folder-plus-DP9sFr26.js → folder-plus-Cmhq0GcR.js} +1 -1
  67. package/web/assets/{gestures-ZhFAENNZ.js → gestures-Bx9M0le5.js} +1 -1
  68. package/web/assets/{git-branch-BMajF2cu.js → git-branch-DzGWffyD.js} +1 -1
  69. package/web/assets/{homeCardStatus-5R7XkxFL.js → homeCardStatus-NAk4A77P.js} +1 -1
  70. package/web/assets/{i18n.generated-DW_l6CkR.js → i18n.generated-D4-Wu9Wh.js} +1 -1
  71. package/web/assets/imageStudio-D67oElIb.js +4 -0
  72. package/web/assets/{index-COzdD7mZ.js → index-3VWZ1rsL.js} +1 -1
  73. package/web/assets/{index-bF04pF8q.js → index-58wBjkHy.js} +1 -1
  74. package/web/assets/{index-Cg1FWM_p.js → index-B9_zH7f5.js} +1 -1
  75. package/web/assets/index-BQrMYjou.js +1 -0
  76. package/web/assets/{index-D-ClOPbg.js → index-BWrWMYua.js} +1 -1
  77. package/web/assets/{index-C--E96Ul.js → index-BdLJBf4-.js} +1 -1
  78. package/web/assets/{index-CI2esW1X.js → index-Bf3W92Hb.js} +1 -1
  79. package/web/assets/{index-B8A3nKeL.js → index-BjmPaLFA.js} +1 -1
  80. package/web/assets/{index-BeW45J9J.js → index-Bv-vJTzF.js} +1 -1
  81. package/web/assets/{index-BnJguNqI.js → index-C7yb62gg.js} +1 -1
  82. package/web/assets/{index-CtRdzpNh.js → index-C9gBBMYv.js} +1 -1
  83. package/web/assets/index-CiQ59Kib.js +1 -0
  84. package/web/assets/{index-DfhEDV2T.js → index-CzTUjEMt.js} +1 -1
  85. package/web/assets/{index-BYKR7EVg.js → index-D4Qx6o3E.js} +1 -1
  86. package/web/assets/{index-jzlU5luC.js → index-DDBcn3UD.js} +1 -1
  87. package/web/assets/{index-CtCYv9bF.js → index-DEADY94l.js} +1 -1
  88. package/web/assets/{index-CWXpOSI2.js → index-DGTKsPAQ.js} +1 -1
  89. package/web/assets/{index-SpegRFQV.js → index-DRwDqvjf.js} +1 -1
  90. package/web/assets/{index-BDZIQnEx.js → index-DexVkoxH.js} +1 -1
  91. package/web/assets/{index-uhvJ8AiJ.js → index-IMOhRWY8.js} +1 -1
  92. package/web/assets/{index-Dr6YmrrT.js → index-XjvpYHIo.js} +1 -1
  93. package/web/assets/{index-fDB1l4d-.js → index-YuejkHoJ.js} +51 -37
  94. package/web/assets/{index-CVLDDD5Z.js → index-pH0266gX.js} +1 -1
  95. package/web/assets/{index-BniT-A2n.js → index-sQl_bGM_.js} +1 -1
  96. package/web/assets/{index-CPfmhZ3Z.js → index-vbNFy5lS.js} +1 -1
  97. package/web/assets/{invitePage-iOT1zBvp.js → invitePage-BT_rFfab.js} +1 -1
  98. package/web/assets/{ipc-SAPDwyQ4.js → ipc-8cxXGSZK.js} +1 -1
  99. package/web/assets/{jszip.min-B3n1FGCb.js → jszip.min-By4OI3XR.js} +1 -1
  100. package/web/assets/launchpad-BX4jQyF4.js +2 -0
  101. package/web/assets/{layout-grid-oIyIGbc5.js → layout-grid-CzxXbCDa.js} +1 -1
  102. package/web/assets/{linkFollow-uke1Xtit.js → linkFollow-J2c0wSgB.js} +4 -4
  103. package/web/assets/{listFold-BeNv2v6M.js → listFold-B_2Xqxn_.js} +1 -1
  104. package/web/assets/{lock-open-D2nMg0ga.js → lock-open-DVWCLSZm.js} +1 -1
  105. package/web/assets/{log-out-D70NCXC4.js → log-out-CdKTS7HC.js} +1 -1
  106. package/web/assets/{magnet-Cqmm97W8.js → magnet-BmVcZ9U4.js} +1 -1
  107. package/web/assets/main-CForzSFD.js +15 -0
  108. package/web/assets/{markdownEditorSurface-zUzFity2.js → markdownEditorSurface-Bs8FJNHu.js} +1 -1
  109. package/web/assets/{mediaPlayer-DB4KUvua.js → mediaPlayer-O9pVRl_k.js} +1 -1
  110. package/web/assets/{message-square-plus-BvUfAAZm.js → message-square-plus-CspBv9iG.js} +1 -1
  111. package/web/assets/{messages-GQUjmbwW.js → messages-CG7ywZ-K.js} +1 -1
  112. package/web/assets/{minimize-2-CMhzL6ZW.js → minimize-2-Bq4vUin-.js} +1 -1
  113. package/web/assets/mobileEntry-CptXQ4Ov.js +13 -0
  114. package/web/assets/modelPickerSurface-C0SkjaPL.js +1 -0
  115. package/web/assets/{nativeDownload-DsGyUSJ5.js → nativeDownload-DlnT8U-y.js} +1 -1
  116. package/web/assets/{nativeSheetMenu--iihXNVd.js → nativeSheetMenu-CVC51DzC.js} +1 -1
  117. package/web/assets/{pageStore-ys8L4rjF.css → pageStore-BC6Z18n7.css} +1 -1
  118. package/web/assets/{pageStore-CyvNZEYX.js → pageStore-D_fKLv-o.js} +7 -7
  119. package/web/assets/{pageTree-Ci2qzrs1.js → pageTree-DtDKozTg.js} +3 -3
  120. package/web/assets/{pen-line-DC3lbEY1.js → pen-line-ho1GgAe2.js} +1 -1
  121. package/web/assets/{pen-tool-DD5_N4lZ.js → pen-tool-CV-FKFEZ.js} +1 -1
  122. package/web/assets/{pencil--sWwxHdP.js → pencil-BgF4Kiqp.js} +1 -1
  123. package/web/assets/{phoneList-DKRMxQHf.js → phoneList-BLVdQcXY.js} +1 -1
  124. package/web/assets/pluginChat-C6t6DWhY.js +2 -0
  125. package/web/assets/{react-b7FrqRQR.js → react-DOzedx9n.js} +1 -1
  126. package/web/assets/recordSurface-C9SRNjy4.js +1 -0
  127. package/web/assets/{redo-2-CqlqhWrI.js → redo-2-DWZTaEz-.js} +1 -1
  128. package/web/assets/{rotate-ccw-D8kni6Ni.js → rotate-ccw-CyZpL7MX.js} +1 -1
  129. package/web/assets/{selectionActions-DIq0xDm8.js → selectionActions-C2a8ImJm.js} +1 -1
  130. package/web/assets/selectionBarSurface-DaXlyy1s.js +1 -0
  131. package/web/assets/{sessionTitle-Ctp4iNKu.js → sessionTitle-BtZ1BteL.js} +1 -1
  132. package/web/assets/settingsPageSurface-Cg8FNZq3.js +1 -0
  133. package/web/assets/{sharePage-CY04XCAf.js → sharePage-vnghra3Q.js} +2 -2
  134. package/web/assets/{shareViewer-DweNF8Ch.js → shareViewer-CWJQHiV-.js} +1 -1
  135. package/web/assets/{star-B0sZEmbj.js → star-ZEpUQwnX.js} +1 -1
  136. package/web/assets/tableSurface-DfEdzVDn.js +1 -0
  137. package/web/assets/{tanguProbe-B8Qv2vcm.js → tanguProbe-BboOas-a.js} +6 -6
  138. package/web/assets/{terminalView-BLGdmdl7.js → terminalView-xp8ARBLi.js} +1 -1
  139. package/web/assets/{type-Dt7RNB9g.js → type-CMyP4cKt.js} +1 -1
  140. package/web/assets/{undo-2-QimgpLBn.js → undo-2-C4ZCsMsx.js} +1 -1
  141. package/web/assets/{unitAccount-DL3jfd84.js → unitAccount-DNxfGo3c.js} +1 -1
  142. package/web/assets/{unitBridge-BSsCy1zP.js → unitBridge-Bq0n1ZM6.js} +1 -1
  143. package/web/assets/{unitCloudTransport-CI_6H0TU.js → unitCloudTransport-CErylgEO.js} +1 -1
  144. package/web/assets/{unitOwnerAccess-CiQ7nD7E.js → unitOwnerAccess-7s-3dfNM.js} +1 -1
  145. package/web/assets/{unitShim-Dl2ksNp-.js → unitShim-BfheyIG8.js} +3 -3
  146. package/web/assets/{upload-Dy7svciS.js → upload-VtCrluEO.js} +1 -1
  147. package/web/assets/userSpaces-BpeYjLni.js +1 -0
  148. package/web/assets/viewportLock-cVUalJAI.js +738 -0
  149. package/web/assets/{zoom-in-DDEtY_Go.js → zoom-in-C7R8s9x-.js} +1 -1
  150. package/web/index.html +2 -2
  151. package/web/assets/CalendarSide-B0RVbOsg.js +0 -1
  152. package/web/assets/CalendarView-BHio-n_r.js +0 -3
  153. package/web/assets/DashboardGridView-CR-R_qV8.js +0 -25
  154. package/web/assets/EventCard-QyYorE1_.js +0 -1
  155. package/web/assets/GitCloneDialog-CbW-RJak.js +0 -1
  156. package/web/assets/ImageStudioView-4WcX0_V4.js +0 -1
  157. package/web/assets/InlineFiles-CAIyTk1n.js +0 -1
  158. package/web/assets/MuseLibraryView-PlS7HAlV.js +0 -2
  159. package/web/assets/PluginToolCard-DCzLhsCA.js +0 -2
  160. package/web/assets/TodoListView-BkgMe44I.js +0 -1
  161. package/web/assets/UnifiedPage-s7-tDSwG.js +0 -712
  162. package/web/assets/automationListSource-B1jz6q0t.js +0 -1
  163. package/web/assets/create-DYmVT68X.js +0 -14
  164. package/web/assets/dbStore-BIG5Mfh2.js +0 -1
  165. package/web/assets/deskCapture-q-jRDIcc.js +0 -1
  166. package/web/assets/imageStudio-DC_syDtx.js +0 -4
  167. package/web/assets/index-CIKPZc3Q.js +0 -1
  168. package/web/assets/index-CmsN2Zm2.js +0 -1
  169. package/web/assets/launchpad-CcmSwlJl.js +0 -2
  170. package/web/assets/main-B9aT0WXG.js +0 -15
  171. package/web/assets/mobileEntry-BnHzrdoC.js +0 -13
  172. package/web/assets/modelPickerSurface-Dtz40Ae2.js +0 -1
  173. package/web/assets/pluginChat-82zZt47Y.js +0 -2
  174. package/web/assets/recordSurface-vUX25Z8R.js +0 -1
  175. package/web/assets/selectionBarSurface-B94e5JW_.js +0 -1
  176. package/web/assets/settingsPageSurface-C9TA3mJg.js +0 -1
  177. package/web/assets/tableSurface-CSBYBw5P.js +0 -1
  178. package/web/assets/userSpaces-oMHIWgYe.js +0 -1
  179. package/web/assets/viewportLock-BZq5PTeN.js +0 -738
package/README.md CHANGED
@@ -20,9 +20,9 @@ node unit/check-sync.mjs
20
20
 
21
21
  When a new stable release is available, merge its tag, resolve conflicts, and run type, plugin, account and local installation checks before building. Verify that fixes in extracted shared handlers are carried forward. The pre-build check refuses exactly one situation: a newer stable tag exists in the repository but not in HEAD's history (packaging from a stale checkout). Any build that is not exactly the tagged commit (later commits, or a package version already bumped past the tag) is recorded in `release.json` as a pre-release rather than refused; a package version behind the baseline tag is refused. It checks fetched tags and does not fetch or merge automatically.
22
22
 
23
- `.github/workflows/check-unit.yml` 提供分支检查和手动构建;发行包中的 `release.json` 记录 Desktop 基线标签与提交、Unit 修订号、是否预发布及源码提交。检查本身不发布版本。
23
+ `.github/workflows/check-unit.yml` 提供分支检查和手动构建;发行包中的 `release.json` 记录 Desktop 基线标签与提交、独立的 `engineVersion`、Unit 修订号、是否预发布及源码提交。桌面与引擎不要求同号,Unit npm 版本仍跟随桌面。检查本身不发布版本。
24
24
 
25
- `.github/workflows/check-unit.yml` provides branch validation and manual builds. Each distribution contains `release.json` with its Desktop baseline tag and commit, Unit revision, pre-release flag and source commit. Validation does not publish a release.
25
+ `.github/workflows/check-unit.yml` provides branch validation and manual builds. Each distribution contains `release.json` with its Desktop baseline tag and commit, independent `engineVersion`, Unit revision, pre-release flag and source commit. Desktop and engine need not share a version; the Unit npm version still follows Desktop. Validation does not publish a release.
26
26
 
27
27
  ## 构建与安装 / Build and install
28
28
 
package/main.mjs CHANGED
@@ -47,7 +47,7 @@ var CORE_BUNDLE_IDS;
47
47
  var init_corePlugins = __esm({
48
48
  "desktop/shared/corePlugins.ts"() {
49
49
  "use strict";
50
- CORE_BUNDLE_IDS = ["forsion-extend", "tangu-computer-use"];
50
+ CORE_BUNDLE_IDS = ["forsion-extend", "tangu-computer-use", "forsion-calendar"];
51
51
  }
52
52
  });
53
53
 
@@ -580,6 +580,7 @@ var IPC = {
580
580
  // 通用 vault 文本文件读写(供插件文件类型 ctx.app.readFile/writeFile;写走自写账本防 watcher 回弹)。
581
581
  readTextFile: "file:read-text",
582
582
  writeTextFile: "file:write-text",
583
+ migrateWorkFolder: "file:migrate-work-folder",
583
584
  /** 外部改动了 vault 里的**非 .md / 非 .db** 文件(附件、片段 .js…)→ ctx.app.watchFile 的数据源。 */
584
585
  fileChange: "file:external-change",
585
586
  /** 每插件一份 JSON blob(~/.forsion/plugins-data/<id>.json);ctx.loadData/saveData 的落点。 */
@@ -703,6 +704,8 @@ var ENGINE_ROUTES = [
703
704
  { method: "GET", path: "/agent/human/:file", access: "deny-remote", src: "routes/human.ts", why: "host human folder (HUMAN / AGENT / SOUL / MEMORY)" },
704
705
  { method: "PUT", path: "/agent/human/:file", access: "deny-remote", src: "routes/human.ts", why: "host human folder write" },
705
706
  { method: "POST", path: "/agent/human/:file/undo", access: "deny-remote", src: "routes/human.ts", why: "host human folder undo" },
707
+ { method: "GET", path: "/agent/human/CALENDAR.db", access: "deny-remote", src: "routes/human.ts", why: "host default calendar (human/CALENDAR.db)" },
708
+ { method: "PUT", path: "/agent/human/CALENDAR.db", access: "deny-remote", src: "routes/human.ts", why: "host default calendar write" },
706
709
  { method: "GET", path: "/agent/project-context/human", access: "deny-remote", src: "routes/human.ts", why: "host collaboration configuration" },
707
710
  { method: "PUT", path: "/agent/project-context/human", access: "deny-remote", src: "routes/human.ts", why: "host collaboration configuration write" },
708
711
  { method: "POST", path: "/agent/project-context/human/undo", access: "deny-remote", src: "routes/human.ts", why: "host collaboration configuration undo" },
@@ -3329,7 +3332,7 @@ init_control();
3329
3332
  // desktop/package.json
3330
3333
  var package_default = {
3331
3334
  name: "forsion-desktop",
3332
- version: "2.13.5",
3335
+ version: "2.13.6",
3333
3336
  description: "Forsion Desktop \u2014 AI \u9A71\u52A8\u7684\u5E94\u7528\u751F\u6001\u7CFB\u7EDF\u7684\u684C\u9762\u7AEF(Electron):Tangu Agent \u5F15\u64CE + LCL \u53EF\u505C\u9760\u5DE5\u4F5C\u533A\u6846\u67B6 + \u53EF\u63D2\u62D4\u529F\u80FD\u7A7A\u95F4(\u5BF9\u8BDD/\u7B14\u8BB0/\u65E5\u5386/\u6536\u4EF6\u7BB1/\u7F16\u7801),\u6309\u4EA7\u54C1\u6863\u6848\u88C1\u51FA\u5168\u5BB6\u6876\u4E0E\u5355\u54C1\u53D1\u884C\u7248",
3334
3337
  author: "Forsion",
3335
3338
  private: true,
@@ -3348,6 +3351,8 @@ var package_default = {
3348
3351
  "check:intelligent-ui-setting": "node scripts/intelligent-ui-setting.check.cjs",
3349
3352
  "demo:sketch": "node scripts/sketch-demo.record.cjs",
3350
3353
  "check:version": "node scripts/dev-version.check.cjs",
3354
+ "check:mini-native-windows": "node scripts/mini-native-windows.e2e.cjs",
3355
+ "check:clip-native-windows": "node scripts/clip-native-windows.e2e.cjs",
3351
3356
  build: "electron-vite build",
3352
3357
  preview: "electron-vite preview",
3353
3358
  web: "vite frontend",
@@ -3363,6 +3368,8 @@ var package_default = {
3363
3368
  "e2e:dnd": "node scripts/block-dnd.e2e.cjs",
3364
3369
  "e2e:sidebardrop": "node scripts/sidebar-drop.e2e.cjs",
3365
3370
  "e2e:notemove": "node scripts/note-move-assets.e2e.cjs",
3371
+ "e2e:notemove:stress": "node scripts/note-move-stress.e2e.cjs",
3372
+ "e2e:notemove:metadata": "node scripts/note-move-metadata.e2e.cjs",
3366
3373
  "e2e:filelink": "node scripts/file-wikilink.e2e.cjs",
3367
3374
  "e2e:ribbon": "node scripts/ribbon-dnd.e2e.cjs",
3368
3375
  "e2e:spacewindow": "node scripts/space-window.e2e.cjs",
@@ -3403,6 +3410,7 @@ var package_default = {
3403
3410
  "e2e:musespace": "node scripts/muse-space.e2e.cjs",
3404
3411
  "e2e:coreplugins": "node scripts/core-plugins.e2e.cjs",
3405
3412
  "e2e:restart-update": "node scripts/restart-update.e2e.cjs",
3413
+ "check:engine-update-live": "node scripts/engine-update.live.check.cjs",
3406
3414
  "e2e:market-submissions": "node scripts/market-submissions.e2e.cjs",
3407
3415
  "e2e:storepages": "node scripts/store-pages.e2e.cjs",
3408
3416
  "e2e:market-auto-update": "node scripts/market-auto-update.e2e.cjs",
@@ -3552,6 +3560,7 @@ var package_default = {
3552
3560
  "e2e:cusettings": "node scripts/computer-use-settings.e2e.cjs",
3553
3561
  "check:uifont": "node scripts/ui-font.check.cjs",
3554
3562
  "check:topchrome": "node scripts/top-chrome.check.cjs",
3563
+ "check:tabtitlebar": "node scripts/tab-titlebar.e2e.cjs",
3555
3564
  "check:minicard": "node scripts/mini-card.check.cjs",
3556
3565
  "check:minidock": "node scripts/mini-dock.e2e.cjs",
3557
3566
  "check:floatingpanel": "node scripts/floating-panel.check.cjs",
@@ -3561,7 +3570,9 @@ var package_default = {
3561
3570
  "check:windows-updater": "node scripts/windows-updater.check.cjs",
3562
3571
  "check:windows-apprefs": "node scripts/windows-apprefs.check.cjs",
3563
3572
  "e2e:windows-clip": "node scripts/windows-clip.e2e.cjs",
3573
+ "e2e:windows-clip-browser": "node scripts/windows-clip-browser.check.cjs",
3564
3574
  "e2e:windows-legacy": "node scripts/windows-legacy-state.e2e.cjs",
3575
+ "e2e:windows-upgrade": "node scripts/windows-upgrade.e2e.cjs",
3565
3576
  "check:persistignore": "node scripts/persist-ignore.check.cjs",
3566
3577
  "check:spaceicon": "node scripts/space-icon.check.cjs",
3567
3578
  "check:spacehidden": "node scripts/plugin-space-hidden.check.cjs",
@@ -3580,6 +3591,7 @@ var package_default = {
3580
3591
  "check:callout": "node scripts/callout-fold.check.cjs",
3581
3592
  "check:typejitter": "node scripts/type-jitter.probe.cjs",
3582
3593
  "check:toggle": "node scripts/e2e-editor.cjs --check=toggle-block",
3594
+ "check:toggleenter:electron": "node scripts/toggle-block.electron.cjs --double-enter",
3583
3595
  "check:togglecaret": "node scripts/e2e-editor.cjs --check=toggle-caret",
3584
3596
  "check:togglecontent": "node scripts/e2e-editor.cjs --check=toggle-content",
3585
3597
  "check:togglemotion": "node scripts/e2e-editor.cjs --check=toggle-motion",
@@ -3629,6 +3641,7 @@ var package_default = {
3629
3641
  "check:streamrenew": "node scripts/stream-renew.check.cjs",
3630
3642
  "check:phonedist": "node scripts/lib/phone-dist-stamp.selftest.cjs",
3631
3643
  "check:unitswitcher": "node scripts/unit-switcher.check.cjs",
3644
+ "check:device-sidebar": "node scripts/e2e-editor.cjs --check=device-sidebar",
3632
3645
  "e2e:unitsettings": "node scripts/unit-settings.e2e.cjs",
3633
3646
  "e2e:unitpublic": "npx tsx scripts/unit-public-extend.e2e.ts",
3634
3647
  "check:secrets": "node scripts/device-secrets.e2e.cjs",
@@ -3682,6 +3695,7 @@ var package_default = {
3682
3695
  "check:shadowsurface": "node scripts/shadow-surface.check.cjs",
3683
3696
  "check:calendarui": "node scripts/calendar-ui.check.cjs",
3684
3697
  "check:calendar-actions": "node scripts/calendar-actions.check.cjs",
3698
+ "e2e:humancal": "node scripts/human-calendar.e2e.cjs",
3685
3699
  "check:astryxscope": "node scripts/astryx-scope.check.cjs",
3686
3700
  "check:astryxhas": "node scripts/astryx-has.check.cjs",
3687
3701
  "check:restylescope": "node scripts/restyle-scope.check.cjs",
@@ -3720,7 +3734,8 @@ var package_default = {
3720
3734
  "e2e:image-studio": "node scripts/image-studio.e2e.cjs",
3721
3735
  "e2e:image-studio:live": "node scripts/image-studio.live.cjs",
3722
3736
  "check:permissions": "node scripts/permissions.check.cjs",
3723
- "check:mininative": "node scripts/mini-auto.check.cjs --native-helper"
3737
+ "check:mininative": "node scripts/mini-auto.check.cjs --native-helper",
3738
+ "e2e:notemove:handoff": "node scripts/note-move-handoff.e2e.cjs"
3724
3739
  },
3725
3740
  dependencies: {
3726
3741
  "@astryxdesign/core": "^0.1.4",
@@ -3732,7 +3747,8 @@ var package_default = {
3732
3747
  "@dnd-kit/sortable": "^10.0.0",
3733
3748
  "@dnd-kit/utilities": "^3.2.2",
3734
3749
  "@excalidraw/excalidraw": "npm:@zsviczian/excalidraw@0.18.122",
3735
- "@forsion/extend": "0.9.1",
3750
+ "@forsion/calendar": "0.1.0",
3751
+ "@forsion/extend": "0.9.2",
3736
3752
  "@forsion/tangu-computer-use": "0.7.1",
3737
3753
  "@milkdown/kit": "^7.21.2",
3738
3754
  "@milkdown/plugin-math": "^7.5.9",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsion/unit",
3
- "version": "2.13.5",
3
+ "version": "2.13.6",
4
4
  "type": "module",
5
5
  "description": "Forsion Unit: the independently runnable Forsion framework (plugin host and Web UI), prebuilt.",
6
6
  "license": "SEE LICENSE IN LICENSE",
package/release.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
- "desktopVersion": "2.13.5",
3
- "desktopTag": "v2.13.5",
4
- "desktopCommit": "8d9bff2af3a52313021c39f430a91e9066c27214",
2
+ "desktopVersion": "2.13.6",
3
+ "engineVersion": "2.13.7",
4
+ "desktopTag": "v2.13.6",
5
+ "desktopCommit": "faed29152287edbf622dfed1928052559d6fe0a9",
5
6
  "unitRevision": 0,
6
7
  "prerelease": false,
7
- "sourceCommit": "8d9bff2af3a52313021c39f430a91e9066c27214",
8
+ "sourceCommit": "faed29152287edbf622dfed1928052559d6fe0a9",
8
9
  "sourceDirty": false,
9
- "builtAt": "2026-10-20T22:57:03.093Z",
10
+ "builtAt": "2026-10-21T19:51:50.093Z",
10
11
  "commercialServerIncluded": false
11
12
  }
@@ -1 +1 @@
1
- import{u as D,r as d,j as t}from"./index-fDB1l4d-.js";import{p as F,f as T,A as M,aO as R,s as y,a7 as W,l as V}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import{rp as q,ei as U,jQ as B,rq as N,ao as H,R as O,aW as _,dm as $,rr as K,f9 as Q,u as X}from"./appStore-DDOkzWDA.js";import{u as G}from"./codeStudioStore-BgLfCDK2.js";import{C as J}from"./CapabilityMenu-DyHTEYLr.js";import{c as Y}from"./react-b7FrqRQR.js";/* empty css */import{C as Z}from"./code-xml-DCCD9eCS.js";import{P as aa}from"./pencil--sWwxHdP.js";import{A as ta}from"./arrow-up-right-BptN64d-.js";import"./ipc-SAPDwyQ4.js";import"./nativeDownload-DsGyUSJ5.js";import"./dbStore-BIG5Mfh2.js";import"./drawingStore-CGvTqqYW.js";const ia=[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],ea=F("monitor-down",ia);let p=0;const f=Y((i,l)=>({items:[],status:"loading",async load(){const m=window.tangu?.productsList;if(!m){i({status:"error"});return}const n=++p;l().status!=="ready"&&i({status:"loading"});try{const r=await m();n===p&&i({items:r,status:"ready"})}catch{n===p&&l().status!=="ready"&&i({status:"error"})}}})),v=i=>i instanceof Error?i.message:String(i);function ga(){const{t:i,locale:l}=D(),m=f(a=>a.items),n=f(a=>a.status),r=f(a=>a.load),[k]=d.useState(()=>f.getState().status!=="ready"),[S,o]=d.useState(null),w=T(a=>a.spaces.some(e=>e.id==="coding"))&&!!M("code-studio"),[z,g]=d.useState(()=>Date.now());d.useEffect(()=>{r();const a=()=>{g(Date.now()),r()};return window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}},[r]),d.useEffect(()=>{const a=setInterval(()=>{document.hidden||g(Date.now())},6e4);return()=>clearInterval(a)},[]);const u=(a,e,s=!1)=>X.getState().toast(i(a,e),s),L=a=>{V.getState().openView("product",{id:a.id},"main",{newTab:!0})},C=a=>{window.tangu?.openDetached?.([{type:"product",params:{id:a.id}}])},j=a=>{y("coding"),requestAnimationFrame(()=>{G.getState().openProject(a.root,a.name)})},E=async a=>{const e=window.tangu?.productsShortcut;if(e){o(a.id);try{const{key:s,error:c,vars:h}=K(await e(a.id,i("artificial.shortcut.fallbackName")));u(s,h,c)}catch(s){u("artificial.toast.shortcutFailed",{detail:v(s)},!0)}finally{o(null)}}},A=async a=>{const e=window.tangu?.productsUpdate;if(!e)return;const s=(await Q(i("artificial.rename.title"),a.name,{label:i("artificial.rename.label")}))?.trim();if(!(!s||s===a.name)){o(a.id);try{await e(a.id,{name:s}),await r()}catch(c){u("artificial.toast.renameFailed",{detail:v(c)},!0)}finally{o(null)}}},I=async a=>{const e=window.tangu?.productsTrash;if(!(!e||!window.confirm(i(a.external?"artificial.remove.confirm":"artificial.trash.confirm",{name:a.name})))){o(a.id);try{await e(a.id,{action:a.external?"unregister":"trash",dirId:a.dirId}),await r()}catch(s){u("artificial.toast.trashFailed",{detail:v(s)},!0)}finally{o(null)}}},P=a=>{const e=N(a.kind),s=e.icon,c=S===a.id,h=[...e.canLaunch&&window.tangu?.openDetached?[{id:"open-window",label:i("artificial.action.openWindow"),icon:t.jsx(H,{size:14}),onSelect:()=>C(a)}]:[],...w?[{id:"edit",label:i("artificial.action.edit"),icon:t.jsx(Z,{size:14}),onSelect:()=>j(a)}]:[],...e.canShortcut&&window.tangu?.productsShortcut?[{id:"shortcut",label:i("artificial.action.shortcut"),icon:t.jsx(ea,{size:14}),onSelect:()=>{E(a)}}]:[],...window.tangu?.revealHostPath?[{id:"reveal",label:i("artificial.action.reveal"),icon:t.jsx(O,{size:14}),onSelect:()=>{window.tangu?.revealHostPath?.(a.root)}}]:[],...window.tangu?.productsUpdate?[{id:"rename",label:i("artificial.action.rename"),icon:t.jsx(aa,{size:14}),onSelect:()=>{A(a)}}]:[],...window.tangu?.productsTrash?[{id:"trash",label:i(a.external?"artificial.action.remove":"artificial.action.trash"),icon:t.jsx(_,{size:14}),danger:!0,onSelect:()=>{I(a)}}]:[]],b=c||!e.canLaunch&&!w;return t.jsxs("div",{className:"newtab-card art-card","data-artificial-card":!0,"data-product-id":a.id,"data-kind":a.kind,children:[t.jsxs("button",{className:"art-card-main","data-action":"open",disabled:b,"aria-label":e.canLaunch?i("artificial.action.open",{name:a.name}):`${i("artificial.action.edit")} · ${a.name}`,onClick:()=>e.canLaunch?L(a):j(a),children:[t.jsx("span",{className:"newtab-card-ic",children:t.jsx(s,{size:18})}),t.jsx("span",{className:"art-card-name",title:a.name,children:a.name}),!b&&t.jsx(ta,{size:14,className:"art-card-go","aria-hidden":!0})]}),t.jsxs("div",{className:"art-card-foot",children:[t.jsxs("div",{className:"art-card-meta",children:[t.jsx("span",{children:$(a.updatedAt,{now:z,locale:l})}),a.published&&t.jsx("span",{className:"art-badge","data-badge":"published",children:i("artificial.badge.published")}),a.kind==="plugin"&&a.devLoad&&t.jsx("span",{className:"art-badge","data-badge":"devload",children:i("artificial.badge.devLoad")})]}),h.length>0&&t.jsx(J,{label:i("artificial.action.more",{name:a.name}),className:"icon-btn art-card-more",disabled:c,items:h,children:t.jsx(W,{size:14})})]})]},a.id)},x=q(m);return t.jsx("div",{className:"art-root","data-artificial-root":!0,children:t.jsxs("div",{className:"art-inner",children:[t.jsxs("div",{className:"art-head",children:[t.jsx(U,{size:18}),t.jsxs("div",{className:"art-titles",children:[t.jsx("div",{className:"art-title",children:i("view.artificial")}),t.jsx("div",{className:"art-sub",children:i("artificial.subtitle")})]}),t.jsx("button",{className:"icon-btn","data-action":"refresh",title:i("artificial.refresh"),"aria-label":i("artificial.refresh"),onClick:()=>{r()},children:t.jsx(B,{size:14})})]}),n==="loading"&&t.jsxs("div",{className:"art-loading","data-state":"loading",children:[t.jsx(R,{variant:"list"}),t.jsx("span",{className:"art-sr-only",role:"status",children:i("artificial.loading")})]}),n==="error"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"error",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.loadFailed")}),t.jsx("button",{className:"btn sm","data-action":"retry",onClick:()=>{r()},children:i("common.retry")})]}),n==="ready"&&!x.length&&t.jsxs("div",{className:"art-state","data-state":"empty",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.empty.title")}),t.jsx("p",{children:i("artificial.empty.body")}),w&&t.jsx("button",{className:"btn primary sm","data-action":"go-coding",onClick:()=>y("coding"),children:i("artificial.empty.cta")})]}),n==="ready"&&x.length>0&&t.jsx("div",{className:k?"sk-fade-in":void 0,children:x.map(a=>t.jsxs("div",{className:"newtab-sec","data-kind-group":a.kind,children:[t.jsx("div",{className:"newtab-sec-title",children:i(N(a.kind).labelKey)}),t.jsx("div",{className:"newtab-grid art-grid",children:a.items.map(P)})]},a.kind))})]})})}export{ga as ArtificialView};
1
+ import{u as D,r as d,j as t}from"./index-YuejkHoJ.js";import{p as F,f as T,A as q,aO as M,s as y,a7 as W,l as R}from"./pageStore-D_fKLv-o.js";import"./client-DD5czSuF.js";import{qW as V,e8 as U,jb as _,qX as N,aj as B,E as H,aQ as O,de as X,qY as $,e_ as K,u as Q}from"./appStore-BskcSDl6.js";import{u as Y}from"./codeStudioStore-OswE1_s0.js";import{C as G}from"./CapabilityMenu-Dzn6RbB1.js";import{c as J}from"./react-DOzedx9n.js";/* empty css */import{C as Z}from"./code-xml-vTB4LtTf.js";import{P as aa}from"./pencil-BgF4Kiqp.js";import{A as ta}from"./arrow-up-right-DEykpgsH.js";import"./dbStore-Bc2lC8ZI.js";import"./ipc-8cxXGSZK.js";import"./nativeDownload-DlnT8U-y.js";import"./drawingStore-BD5m2eqn.js";const ia=[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]],ea=F("monitor-down",ia);let p=0;const f=J((i,l)=>({items:[],status:"loading",async load(){const m=window.tangu?.productsList;if(!m){i({status:"error"});return}const n=++p;l().status!=="ready"&&i({status:"loading"});try{const r=await m();n===p&&i({items:r,status:"ready"})}catch{n===p&&l().status!=="ready"&&i({status:"error"})}}})),v=i=>i instanceof Error?i.message:String(i);function ga(){const{t:i,locale:l}=D(),m=f(a=>a.items),n=f(a=>a.status),r=f(a=>a.load),[k]=d.useState(()=>f.getState().status!=="ready"),[S,o]=d.useState(null),w=T(a=>a.spaces.some(e=>e.id==="coding"))&&!!q("code-studio"),[z,g]=d.useState(()=>Date.now());d.useEffect(()=>{r();const a=()=>{g(Date.now()),r()};return window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}},[r]),d.useEffect(()=>{const a=setInterval(()=>{document.hidden||g(Date.now())},6e4);return()=>clearInterval(a)},[]);const u=(a,e,s=!1)=>Q.getState().toast(i(a,e),s),E=a=>{R.getState().openView("product",{id:a.id},"main",{newTab:!0})},L=a=>{window.tangu?.openDetached?.([{type:"product",params:{id:a.id}}])},j=a=>{y("coding"),requestAnimationFrame(()=>{Y.getState().openProject(a.root,a.name)})},C=async a=>{const e=window.tangu?.productsShortcut;if(e){o(a.id);try{const{key:s,error:c,vars:h}=$(await e(a.id,i("artificial.shortcut.fallbackName")));u(s,h,c)}catch(s){u("artificial.toast.shortcutFailed",{detail:v(s)},!0)}finally{o(null)}}},A=async a=>{const e=window.tangu?.productsUpdate;if(!e)return;const s=(await K(i("artificial.rename.title"),a.name,{label:i("artificial.rename.label")}))?.trim();if(!(!s||s===a.name)){o(a.id);try{await e(a.id,{name:s}),await r()}catch(c){u("artificial.toast.renameFailed",{detail:v(c)},!0)}finally{o(null)}}},I=async a=>{const e=window.tangu?.productsTrash;if(!(!e||!window.confirm(i(a.external?"artificial.remove.confirm":"artificial.trash.confirm",{name:a.name})))){o(a.id);try{await e(a.id,{action:a.external?"unregister":"trash",dirId:a.dirId}),await r()}catch(s){u("artificial.toast.trashFailed",{detail:v(s)},!0)}finally{o(null)}}},P=a=>{const e=N(a.kind),s=e.icon,c=S===a.id,h=[...e.canLaunch&&window.tangu?.openDetached?[{id:"open-window",label:i("artificial.action.openWindow"),icon:t.jsx(B,{size:14}),onSelect:()=>L(a)}]:[],...w?[{id:"edit",label:i("artificial.action.edit"),icon:t.jsx(Z,{size:14}),onSelect:()=>j(a)}]:[],...e.canShortcut&&window.tangu?.productsShortcut?[{id:"shortcut",label:i("artificial.action.shortcut"),icon:t.jsx(ea,{size:14}),onSelect:()=>{C(a)}}]:[],...window.tangu?.revealHostPath?[{id:"reveal",label:i("artificial.action.reveal"),icon:t.jsx(H,{size:14}),onSelect:()=>{window.tangu?.revealHostPath?.(a.root)}}]:[],...window.tangu?.productsUpdate?[{id:"rename",label:i("artificial.action.rename"),icon:t.jsx(aa,{size:14}),onSelect:()=>{A(a)}}]:[],...window.tangu?.productsTrash?[{id:"trash",label:i(a.external?"artificial.action.remove":"artificial.action.trash"),icon:t.jsx(O,{size:14}),danger:!0,onSelect:()=>{I(a)}}]:[]],b=c||!e.canLaunch&&!w;return t.jsxs("div",{className:"newtab-card art-card","data-artificial-card":!0,"data-product-id":a.id,"data-kind":a.kind,children:[t.jsxs("button",{className:"art-card-main","data-action":"open",disabled:b,"aria-label":e.canLaunch?i("artificial.action.open",{name:a.name}):`${i("artificial.action.edit")} · ${a.name}`,onClick:()=>e.canLaunch?E(a):j(a),children:[t.jsx("span",{className:"newtab-card-ic",children:t.jsx(s,{size:18})}),t.jsx("span",{className:"art-card-name",title:a.name,children:a.name}),!b&&t.jsx(ta,{size:14,className:"art-card-go","aria-hidden":!0})]}),t.jsxs("div",{className:"art-card-foot",children:[t.jsxs("div",{className:"art-card-meta",children:[t.jsx("span",{children:X(a.updatedAt,{now:z,locale:l})}),a.published&&t.jsx("span",{className:"art-badge","data-badge":"published",children:i("artificial.badge.published")}),a.kind==="plugin"&&a.devLoad&&t.jsx("span",{className:"art-badge","data-badge":"devload",children:i("artificial.badge.devLoad")})]}),h.length>0&&t.jsx(G,{label:i("artificial.action.more",{name:a.name}),className:"icon-btn art-card-more",disabled:c,items:h,children:t.jsx(W,{size:14})})]})]},a.id)},x=V(m);return t.jsx("div",{className:"art-root","data-artificial-root":!0,children:t.jsxs("div",{className:"art-inner",children:[t.jsxs("div",{className:"art-head",children:[t.jsx(U,{size:18}),t.jsxs("div",{className:"art-titles",children:[t.jsx("div",{className:"art-title",children:i("view.artificial")}),t.jsx("div",{className:"art-sub",children:i("artificial.subtitle")})]}),t.jsx("button",{className:"icon-btn","data-action":"refresh",title:i("artificial.refresh"),"aria-label":i("artificial.refresh"),onClick:()=>{r()},children:t.jsx(_,{size:14})})]}),n==="loading"&&t.jsxs("div",{className:"art-loading","data-state":"loading",children:[t.jsx(M,{variant:"list"}),t.jsx("span",{className:"art-sr-only",role:"status",children:i("artificial.loading")})]}),n==="error"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"error",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.loadFailed")}),t.jsx("button",{className:"btn sm","data-action":"retry",onClick:()=>{r()},children:i("common.retry")})]}),n==="ready"&&!x.length&&t.jsxs("div",{className:"art-state","data-state":"empty",children:[t.jsx("div",{className:"art-state-title",children:i("artificial.empty.title")}),t.jsx("p",{children:i("artificial.empty.body")}),w&&t.jsx("button",{className:"btn primary sm","data-action":"go-coding",onClick:()=>y("coding"),children:i("artificial.empty.cta")})]}),n==="ready"&&x.length>0&&t.jsx("div",{className:k?"sk-fade-in":void 0,children:x.map(a=>t.jsxs("div",{className:"newtab-sec","data-kind-group":a.kind,children:[t.jsx("div",{className:"newtab-sec-title",children:i(N(a.kind).labelKey)}),t.jsx("div",{className:"newtab-grid art-grid",children:a.items.map(P)})]},a.kind))})]})})}export{ga as ArtificialView};
@@ -1 +1 @@
1
- import{r as o,j as e,u as xe}from"./index-fDB1l4d-.js";import{p3 as le,b0 as Ze,k9 as Je,k5 as Qe,j2 as et,kc as tt,p4 as at,i as nt,ag as it,p5 as lt,p6 as $e,p7 as Ie,dp as Fe,p8 as Re,hK as be,p9 as st,aW as pe,pa as ot,pb as rt,aU as ut,aV as dt,L as ct,W as mt,iY as ht,pc as bt,pd as pt,l as xt,pe as vt,pf as jt,u as gt}from"./appStore-DDOkzWDA.js";import{p as ft,T as yt,b7 as Nt,bv as _t,aj as Ct,ba as kt,b9 as wt,u as St,Z as De,q as Te,a6 as Et,am as Pt,B as $t,D as Ft,as as Rt}from"./pageStore-CyvNZEYX.js";import{u as ie}from"./dbStore-BIG5Mfh2.js";import{C as Dt}from"./CapabilityMenu-DyHTEYLr.js";import{u as Tt}from"./gestures-ZhFAENNZ.js";import{a as zt,C as Mt}from"./Chrome-C7F6fdDp.js";import{d as It,e as At,f as qt,g as Ht}from"./canvasPrefs-ArsX3NFO.js";import{R as Vt}from"./rotate-ccw-D8kni6Ni.js";import"./messages-GQUjmbwW.js";const Wt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Lt=ft("circle-question-mark",Wt);function Ot({controller:i,open:c,title:b,onClose:C,children:h}){const[j]=o.useState(()=>document.createElement("div"));j.className="auto-extension";const a=o.useRef(null),k=o.useRef(C);k.current=C;const v=o.useRef(b);return v.current=b,o.useEffect(()=>{if(!(!i||!c)){try{a.current=i.open({id:"automation-context",title:()=>v.current,mount:f=>(f.appendChild(j),()=>j.remove()),onClose:()=>k.current()})}catch{k.current()}return()=>{a.current?.close(),a.current=null}}},[i,c,j]),c?i?yt.createPortal(h,j):e.jsx("div",{className:"auto-extension auto-extension-inline",children:h}):null}const oa=["reminder","briefing","table","button"];function Bt(i,c){return i?i==="briefing"||i==="button"?[{...le("agent_run"),prompt:c(`automation.ux.${i}.prompt`)}]:[{...le("notify"),title:c(`automation.ux.${i}.name`),body:c(`automation.ux.${i}.body`)}]:[le("notify")]}function ze(i,c,b){if(i.type==="notify")return i.title.trim()?null:"notify";if(i.type==="agent_run")return i.agentSlug?i.prompt.trim()?null:"prompt":"agent";if(i.type==="db_row_add"||i.type==="db_row_edit"){if(!/\.db$/i.test(i.dbPath.trim()))return"table";if(!i.cells.some(h=>h.k.trim()))return"cells";if(i.type==="db_row_edit"){if(c!=="db_changed"&&(!i.rowId.trim()&&!i.matchColumn.trim()||i.rowFrom.trim()))return"row";if(i.matchColumn.trim()&&!i.matchValue.trim())return"match"}return null}const C=b.find(h=>h.name===i.tool);if(!C)return"tool";if((C.parameters.required||[]).some(h=>!(i.argValues[h]||"").trim()))return"args";for(const[h,j]of Object.entries(i.argValues)){if(!j.trim())continue;const a=C.parameters.properties?.[h];if(a?.type==="number"&&!Number.isFinite(Number(j)))return"args";if(a?.type==="object"||a?.type==="array")try{const k=JSON.parse(j);if(a.type==="array"?!Array.isArray(k):!k||typeof k!="object"||Array.isArray(k))return"json"}catch{return"json"}}return null}function Ut(i){return(i||[]).map(c=>({value:`{{row.${c.id}}}`,label:c.name}))}const Kt=i=>({x:0,y:i*132,w:244,h:84}),Yt=({nodes:i,selected:c,onSelect:b,children:C})=>{const{t:h}=xe(),j=o.useId().replace(/:/g,""),a=o.useRef(null),[k,v]=o.useState({}),[f,$]=o.useState(It),[I,F]=o.useState(At),p=Nt(a),m=new Map(i.map((n,s)=>[n.id,k[n.id]||Kt(s)])),P=i.map(n=>n.id).join(","),x=Tt(a,p,{boxes:()=>m,identity:()=>P,commit:n=>v(s=>({...s,...Object.fromEntries(n)})),hitKey:n=>n.closest("[data-flow-node]")?.dataset.flowNode||null,onEnterEdit:b,onDoubleClick:n=>{n&&b(n)},minW:244,minH:84,repel:!0},f);o.useEffect(()=>x.bind(a.current),[x.bind]),o.useEffect(()=>p.bindWheel(a.current),[p.bindWheel]);const D=o.useRef(()=>p.fitTo([...m.values()],64));D.current=()=>p.fitTo([...m.values()],64),o.useEffect(()=>{v({});const n=requestAnimationFrame(()=>D.current());return()=>cancelAnimationFrame(n)},[P]),o.useEffect(()=>{const n=new ResizeObserver(()=>D.current());return a.current&&n.observe(a.current),()=>n.disconnect()},[]);const A=n=>x.live?.get(n)||m.get(n);return e.jsx("div",{className:"auto-canvas-shell am-app",children:e.jsxs("div",{className:"auto-canvas amx-stage",ref:a,tabIndex:0,"aria-label":h("automation.ux.flow"),onPointerUpCapture:n=>{if(x.busy)return;const s=document.elementFromPoint(n.clientX,n.clientY)?.closest("[data-flow-node]");s&&a.current?.contains(s)&&b(s.dataset.flowNode)},children:[e.jsx("div",{className:"amx-stage-grid",style:_t(p.vp)}),e.jsxs("div",{className:"auto-canvas-world",style:{transform:`translate(${p.vp.x}px, ${p.vp.y}px) scale(${p.vp.z})`},children:[e.jsxs("svg",{className:"auto-canvas-edges","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsx("marker",{id:j,markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:e.jsx("path",{d:"M0,0 L6,3 L0,6",fill:"none",stroke:"currentColor"})})}),i.slice(1).map((n,s)=>{const y=A(i[s].id),w=A(n.id),q=y.x+y.w/2,H=y.y+y.h,X=w.x+w.w/2,W=w.y;return e.jsx("path",{d:`M${q},${H} C${q},${H+28} ${X},${W-28} ${X},${W}`,markerEnd:`url(#${j})`},n.id)})]}),i.map(n=>{const s=A(n.id);return e.jsxs("div",{"data-flow-node":n.id,role:"button",tabIndex:0,"aria-pressed":c===n.id,className:`auto-flow-node ${c===n.id?"selected":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},onClick:()=>b(n.id),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),b(n.id))},children:[e.jsx("span",{className:"auto-flow-icon",children:n.icon}),e.jsx("strong",{children:n.title}),e.jsx("span",{className:"auto-flow-status",title:h(n.ready?"automation.ux.ready":"automation.ux.incomplete"),children:n.ready?e.jsx(Ct,{size:13}):e.jsx(Ze,{size:13})}),e.jsx("span",{className:"auto-flow-subtitle",children:n.subtitle})]},n.id)}),x.marquee&&e.jsx("div",{className:"amx-stage-marquee",style:{left:x.marquee.x,top:x.marquee.y,width:x.marquee.w,height:x.marquee.h}})]}),C&&e.jsx("div",{className:"amx-stage-tools auto-canvas-tools",children:C}),e.jsx(zt,{zoom:p.vp.z,onZoomBy:n=>{const{w:s,h:y}=kt(a.current);p.setVp(wt(p.vp,p.vp.z*n,s/2,y/2))},onFit:()=>D.current(),snap:f,onSnap:n=>{$(n),Ht(n)},mini:I,onMini:n=>{F(n),qt(n)},extra:e.jsx("button",{type:"button",title:h("automation.ux.arrange"),onClick:()=>{v({}),requestAnimationFrame(()=>D.current())},children:e.jsx(Vt,{size:12})})}),I&&e.jsx(Mt,{hostRef:a,vp:p.vp,items:i.map(n=>({key:n.id,kind:"card",box:A(n.id)})),onCenter:p.centerOn})]})})},Me=({label:i,value:c,onChange:b,multiline:C,maxLength:h=4e3,placeholder:j,columns:a,hasRow:k})=>{const{t:v}=xe(),f=o.useId(),$=o.useRef(null),I=o.useRef({start:c.length,end:c.length}),F=m=>{if(!m)return;const{start:P,end:x}=I.current;c.length-(x-P)+m.length>h||(b(c.slice(0,P)+m+c.slice(x)),requestAnimationFrame(()=>{$.current?.focus(),$.current?.setSelectionRange(P+m.length,P+m.length)}))},p={id:f,ref:$,value:c,maxLength:h,placeholder:j,onChange:m=>b(m.target.value),onSelect:m=>{I.current={start:m.currentTarget.selectionStart??c.length,end:m.currentTarget.selectionEnd??c.length}}};return e.jsxs("div",{className:"field auto-template-field",children:[e.jsxs("div",{className:"auto-field-heading",children:[e.jsx("label",{htmlFor:f,children:i}),e.jsxs("select",{"aria-label":v("automation.ux.insertVariable",{field:i}),value:"",onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:v("automation.ux.variables")}),e.jsx("option",{value:"{{today}}",children:v("automation.ux.today")}),e.jsx("option",{value:"{{now}}",children:v("automation.ux.now")}),k&&e.jsxs("optgroup",{label:v("automation.ux.triggerRow"),children:[e.jsx("option",{value:"{{row.id}}",children:v("automation.ux.rowId")}),Ut(a).map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))]})]})]}),C?e.jsx("textarea",{...p}):e.jsx("input",{type:"text",...p})]})};function Gt(){const i=new Date(Date.now()+36e5);i.setMinutes(0,0,0);const c=b=>String(b).padStart(2,"0");return`${i.getFullYear()}-${c(i.getMonth()+1)}-${c(i.getDate())}T${c(i.getHours())}:00`}const Xt=({editing:i,starter:c,fixedManual:b,onSaved:C,onCancel:h,extendView:j})=>{const{t:a}=xe(),k=Je(),v=Qe(),f=v.actionsCatalog,[$,I]=o.useState(i?.desc||(c?a(`automation.ux.${c}.name`):"")),[F,p]=o.useState("trigger"),[m,P]=o.useState(!1),x=t=>{p(t),P(!0)},[D,A]=o.useState(i?.enabled??!!b),n=i?.cond,[s,y]=o.useState(n?n.type==="event_seen"?"event_seen":n.type==="file_chars_gte"?"file_chars_gte":n.type==="manual"?"manual":n.type==="db_changed"?"db_changed":"timer":b||c==="button"?"manual":c==="table"?"db_changed":"timer"),[w,q]=o.useState(n?.type==="at"?"at":n?.type==="every"?"every":"daily_at"),[H,X]=o.useState(n?.type==="daily_at"?n.time:"09:00"),W=!!i&&et(i),[Z,Ae]=o.useState(n?.type==="at"&&!W?n.datetime.replace(" ","T"):Gt()),J=n?.type==="every"?/^(\d+)([mhd])$/.exec(n.interval):null,[Q,qe]=o.useState(J?J[1]:"1"),[ve,He]=o.useState(J?J[2]:"h"),[se,Ve]=o.useState(n?.type==="event_seen"?n.match:""),[oe,We]=o.useState(n?.type==="file_chars_gte"?n.path:""),[re,Le]=o.useState(n?.type==="file_chars_gte"?String(n.n):"100"),[R,Oe]=o.useState(n?.type==="db_changed"?n.path:""),[z,je]=o.useState(n?.type==="db_changed"?n.event:"row_added"),[V,ge]=o.useState(()=>tt(n)),fe=(t,d)=>ge(r=>d?r.includes(t)?r:[...r,t]:r.filter(l=>l!==t)),[ue,Be]=o.useState(n?.type==="db_changed"&&n.equals||""),[L,de]=o.useState(()=>at(n)),ce=(t,d)=>de(r=>r.map((l,u)=>u===t?{...l,...d}:l));o.useEffect(()=>{nt()},[]);const ye=St(t=>t.files),O=o.useMemo(()=>ye.filter(t=>/\.db$/i.test(t)),[ye]);o.useEffect(()=>{for(const t of O)ie.getState().load(t,t)},[O]);const Ne=ie(it(t=>O.filter(d=>t.entries[d]?.data?.source!==void 0))),ee=o.useMemo(()=>O.filter(t=>!Ne.includes(t)),[O,Ne]),B=ie(t=>s==="db_changed"&&R?t.entries[R]?.data?.columns:void 0),U=o.useMemo(()=>B?.filter(t=>t.type!=="formula"&&t.type!=="lookup"),[B]),[S,te]=o.useState(()=>i?lt(i):Bt(c,a)),[me,Ue]=o.useState(i&&!i.actions?.length&&!i.agentSlug&&i.prompt||""),[K,_e]=o.useState(()=>$e(i,s)),Ce=o.useRef(!1);o.useEffect(()=>{!i&&!Ce.current&&_e($e(null,s))},[s,i]);const[Y,ke]=o.useState(!1),[we,ae]=o.useState(""),Ke=t=>{if(S.length>=24)return;const d=le(t);te(r=>[...r,d]),x(String(d.key))},Se=S.some(t=>t.type==="agent_run"),g=(t,d)=>te(r=>r.map(l=>l.key===t?{...l,...d}:l)),Ee=(t,d)=>te(r=>{const l=t+d;if(l<0||l>=r.length)return r;const u=[...r];return[u[t],u[l]]=[u[l],u[t]],u});if(Ie(i))return e.jsxs("div",{className:"auto-builder",children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(Fe,{size:17})," ",a("automation.builder.editTitle")]}),e.jsx("div",{className:"auto-node",children:e.jsx("div",{className:"auto-hint",children:a("automation.builder.unsupported")})}),e.jsx("div",{className:"auto-builder-actions",children:e.jsx("button",{className:"btn ghost",onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})})]});const Pe=!(s==="timer"&&(w==="daily_at"&&!/^\d{1,2}:\d{2}$/.test(H)||w==="at"&&!Z||w==="every"&&(!Number.isInteger(Number(Q))||Number(Q)<1))||s==="event_seen"&&!se.trim()||s==="file_chars_gte"&&(!oe.trim()||!(Number(re)>0))||s==="db_changed"&&(!/\.db$/i.test(R.trim())||z==="cell_changed"&&!V.length||L.length>Re||L.some(t=>t.column.trim()&&(t.op==="eq"||t.op==="ne")&&!t.value.trim()))),E=[];$.trim()||E.push({node:"trigger",text:a("automation.ux.issue.name")}),Pe||E.push({node:"trigger",text:a("automation.ux.issue.trigger")}),!S.length&&(!i||s==="manual")&&E.push({node:"review",text:a("automation.ux.issue.steps")}),S.forEach((t,d)=>{const r=ze(t,s,f);r&&E.push({node:String(t.key),text:`${d+1}. ${a(`automation.ux.issue.${r}`)}`})}),s!=="timer"&&s!=="manual"&&(!K.trim()||!Number.isFinite(Number(K))||Number(K)<0)&&E.push({node:"review",text:a("automation.ux.issue.cooldown")});const ne=E.length===0,Ye=async()=>{if(!ne||Y)return;const t=s==="timer"?w:s;if(t==="at"&&(ht(Z)?.getTime()??0)<Date.now()-5*6e4){ae(a("automation.builder.atPast"));return}const d=u=>ie.getState().entries[u]?.data?.source!==void 0;if([...t==="db_changed"?[R.trim()]:[],...S.filter(u=>u.type==="db_row_add"||u.type==="db_row_edit").map(u=>u.dbPath.trim())].filter(Boolean).some(d)){ae(a("automation.builder.dbNoteView"));return}ke(!0),ae("");const l=bt(S,f);try{const u=await pt(xt(),{id:i?.id,actor:"user",desc:$.trim(),cond_type:t,time:t==="daily_at"?H:void 0,datetime:t==="at"?Z:void 0,interval:t==="every"?`${Math.floor(Number(Q))}${ve}`:void 0,match:t==="event_seen"?se.trim():void 0,path:t==="file_chars_gte"?oe.trim():t==="db_changed"?R.trim():void 0,n:t==="file_chars_gte"?Number(re):void 0,event:t==="db_changed"?z:void 0,column_id:t==="db_changed"&&z==="cell_changed"?V[0]:void 0,column_ids:t==="db_changed"&&z==="cell_changed"&&V.length>1?V:void 0,equals:t==="db_changed"&&z==="cell_changed"&&ue.trim()?ue.trim():void 0,where:t==="db_changed"?jt(L):void 0,vault:t==="db_changed"&&i?.cond.type==="db_changed"?i.cond.vault:void 0,prompt:S.length?void 0:me.trim()||void 0,cooldown_hours:vt(s,K),actions:S.length?l:null,enabled:D});if(i?.id||Rt("automation.create"),C){v.bump(),C(u);return}v.acceptSaved(u),gt.getState().toast(a("automation.ux.saved"))}catch(u){ae(String(u?.message||u))}finally{ke(!1)}},he=t=>t==="notify"?e.jsx(ct,{size:14}):t==="agent_run"?e.jsx($t,{size:14}):t==="db_row_add"||t==="db_row_edit"?e.jsx(Ft,{size:14}):e.jsx(mt,{size:14}),Ge=[{id:"trigger",title:a("automation.builder.trigger"),subtitle:a(`automation.builder.${s==="timer"?"condTimer":s==="manual"?"condManual":s==="db_changed"?"condDb":s==="event_seen"?"condEvent":"condFile"}`),icon:e.jsx(De,{size:17}),ready:Pe&&!!$.trim()},...S.map((t,d)=>({id:String(t.key),title:`${d+1}. ${a(`automation.step.${t.type}`)}`,subtitle:t.title||t.prompt||t.dbPath||t.tool||a("automation.ux.setupHint"),icon:he(t.type),ready:!ze(t,s,f)})),...!S.length&&i&&s!=="manual"?[{id:"muse",title:a("automation.builder.museFallback"),subtitle:me||a("automation.builder.museFallbackHint"),icon:e.jsx(Te,{size:17}),ready:!0}]:[],{id:"review",title:a("automation.ux.finish"),subtitle:a(ne?"automation.ux.allReady":"automation.ux.finishHint"),icon:e.jsx(be,{size:17}),ready:ne}],Xe=e.jsxs(e.Fragment,{children:[e.jsxs(Dt,{label:a("automation.ux.addStep"),className:"btn ghost sm",disabled:Y||S.length>=24,items:["notify","agent_run","db_row_add","db_row_edit","tool_call"].map(t=>({id:t,label:a(`automation.step.${t}`),icon:he(t),disabled:t==="tool_call"&&!f.length,onSelect:()=>Ke(t)})),children:[e.jsx(Et,{size:14}),a("automation.ux.addStep")]}),e.jsx("button",{className:"icon-btn",title:a("automation.ux.help"),onClick:()=>x("help"),children:e.jsx(Lt,{size:15})})]});return e.jsxs("div",{className:`auto-builder auto-workflow-builder ${b?"auto-builder-embedded":""}`,children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(Fe,{size:17}),e.jsx("span",{children:a(i?"automation.builder.editTitle":"automation.builder.title")}),e.jsx("button",{className:"btn ghost sm",disabled:Y,onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})]}),e.jsx("div",{className:"auto-builder-workspace",hidden:!j&&m,children:e.jsx(Yt,{nodes:Ge,selected:m?F:"",onSelect:x,children:Xe})}),e.jsxs(Ot,{controller:j,open:m,title:a("automation.ux.setup"),onClose:()=>P(!1),children:[!j&&e.jsxs("button",{className:"btn ghost sm auto-inline-back",onClick:()=>P(!1),children:[e.jsx(Pt,{size:14}),a("automation.ux.flow")]}),e.jsxs("div",{className:"auto-inspector","aria-label":a("automation.ux.setup"),children:[e.jsxs("div",{className:"auto-node",hidden:F!=="trigger",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(De,{size:14})}),a("automation.builder.trigger")]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.desc")}),e.jsx("input",{"aria-label":a("automation.builder.desc"),type:"text",value:$,maxLength:200,placeholder:a("automation.builder.descPh"),onChange:t=>I(t.target.value)})]}),!b&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.condType")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:s==="timer"?"active":"",onClick:()=>y("timer"),children:a("automation.builder.condTimer")}),e.jsx("button",{className:s==="event_seen"?"active":"",onClick:()=>y("event_seen"),children:a("automation.builder.condEvent")}),e.jsx("button",{className:s==="file_chars_gte"?"active":"",onClick:()=>y("file_chars_gte"),children:a("automation.builder.condFile")}),e.jsx("button",{className:s==="db_changed"?"active":"",onClick:()=>y("db_changed"),children:a("automation.builder.condDb")}),e.jsx("button",{className:s==="manual"?"active":"",onClick:()=>y("manual"),children:a("automation.builder.condManual")})]})]}),s==="db_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:R,onChange:t=>{Oe(t.target.value),ge([])},children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(t=>e.jsx("option",{value:t,children:t},t)),R&&!ee.includes(R)&&e.jsx("option",{value:R,children:R})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEvent")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:z==="row_added"?"active":"",onClick:()=>je("row_added"),children:a("automation.builder.dbEventRow")}),e.jsx("button",{className:z==="cell_changed"?"active":"",onClick:()=>je("cell_changed"),children:a("automation.builder.dbEventCell")})]})]}),z==="cell_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbColumn")}),e.jsxs("div",{className:"auto-checks",children:[(U??[]).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:V.includes(t.id),onChange:d=>fe(t.id,d.target.checked)}),t.name]},t.id)),V.filter(t=>!(U??[]).some(d=>d.id===t)).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:!0,onChange:()=>fe(t,!1)}),"(",t,")"]},t)),!U&&e.jsx("span",{className:"auto-hint",children:a("automation.builder.dbColsLoading")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbColumnsHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEquals")}),e.jsx("input",{type:"text",value:ue,maxLength:200,placeholder:a("automation.builder.dbEqualsPh"),onChange:t=>Be(t.target.value)})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbWhere")}),L.map((t,d)=>e.jsxs("div",{className:"auto-inline",children:[e.jsxs("select",{value:t.column,onChange:r=>ce(d,{column:r.target.value}),children:[e.jsx("option",{value:"",children:a(B?"automation.builder.dbPickCol":"automation.builder.dbColsLoading")}),(B??[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),t.column&&!(B??[]).some(r=>r.id===t.column)&&e.jsxs("option",{value:t.column,children:["(",t.column,")"]})]}),e.jsx("select",{value:t.op,onChange:r=>ce(d,{op:r.target.value}),children:st.map(r=>e.jsx("option",{value:r,children:a(r==="eq"?"automation.builder.dbWhereOpEq":r==="ne"?"automation.builder.dbWhereOpNe":r==="empty"?"automation.builder.dbWhereOpEmpty":"automation.builder.dbWhereOpNotEmpty")},r))}),e.jsx("input",{type:"text",value:t.value,maxLength:200,disabled:t.op==="empty"||t.op==="notempty",placeholder:a("automation.builder.dbWhereValPh"),onChange:r=>ce(d,{value:r.target.value})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>de(r=>r.filter((l,u)=>u!==d)),children:e.jsx(pe,{size:12})})]},d)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbWhereAdd"),disabled:L.length>=Re,onClick:()=>de(t=>[...t,{column:"",op:"eq",value:""}]),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbWhereHint")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbHint")})]}),s==="manual"&&e.jsx("div",{className:"auto-hint",children:a("automation.builder.manualHint")}),s==="timer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.timerMode")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:w==="daily_at"?"active":"",onClick:()=>q("daily_at"),children:a("automation.builder.timerDaily")}),e.jsx("button",{className:w==="at"?"active":"",onClick:()=>q("at"),children:a("automation.builder.timerOnce")}),e.jsx("button",{className:w==="every"?"active":"",onClick:()=>q("every"),children:a("automation.builder.timerEvery")})]})]}),w==="daily_at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.time")}),e.jsx("input",{type:"time",value:H,onChange:t=>X(t.target.value)})]}),w==="at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.datetime")}),e.jsx("input",{type:"datetime-local",value:Z,onChange:t=>Ae(t.target.value)}),e.jsx("div",{className:"auto-hint",children:a(W?"automation.builder.expiredReset":"automation.builder.onceHint")})]}),w==="every"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.interval")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"number",value:Q,min:1,style:{width:90},onChange:t=>qe(t.target.value)}),e.jsxs("select",{value:ve,onChange:t=>He(t.target.value),children:[e.jsx("option",{value:"m",children:a("automation.builder.unitM")}),e.jsx("option",{value:"h",children:a("automation.builder.unitH")}),e.jsx("option",{value:"d",children:a("automation.builder.unitD")})]})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.everyHint")})]})]}),s==="event_seen"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.match")}),e.jsx("input",{type:"text",list:"auto-event-catalog",value:se,maxLength:120,placeholder:a("automation.builder.matchPh"),onChange:t=>Ve(t.target.value)}),e.jsxs("datalist",{id:"auto-event-catalog",children:[ot.map(t=>e.jsx("option",{value:t},t)),rt().map(t=>e.jsx("option",{value:t.name,label:t.label},t.name))]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.matchHint")})]}),s==="file_chars_gte"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.path")}),e.jsx("input",{type:"text",value:oe,placeholder:"~/Forsion/Notes/xxx.md",onChange:t=>We(t.target.value)})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.chars")}),e.jsx("input",{type:"number",value:re,min:1,onChange:t=>Le(t.target.value)})]})]})]}),S.map((t,d)=>{const r=t.type==="tool_call"?f.find(l=>l.name===t.tool):void 0;return e.jsxs("div",{className:"auto-node",hidden:F!==String(t.key),children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:he(t.type)}),a("automation.builder.stepN",{n:String(d+1)})," · ",a(`automation.step.${t.type}`),e.jsxs("span",{className:"auto-step-tools",children:[e.jsx("button",{className:"icon-btn",disabled:d===0,title:a("automation.builder.moveUp"),onClick:()=>Ee(d,-1),children:e.jsx(ut,{size:12})}),e.jsx("button",{className:"icon-btn",disabled:d===S.length-1,title:a("automation.builder.moveDown"),onClick:()=>Ee(d,1),children:e.jsx(dt,{size:12})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>{te(l=>l.filter(u=>u.key!==t.key)),x("trigger")},children:e.jsx(pe,{size:12})})]})]}),t.type==="notify"&&e.jsxs(e.Fragment,{children:[e.jsx(Me,{label:a("automation.builder.notifyTitle"),value:t.title,maxLength:200,placeholder:a("automation.builder.notifyTitlePh"),onChange:l=>g(t.key,{title:l}),columns:U,hasRow:s==="db_changed"}),e.jsx(Me,{label:a("automation.builder.notifyBody"),value:t.body,multiline:!0,onChange:l=>g(t.key,{body:l}),columns:U,hasRow:s==="db_changed"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.notifyHint")})]}),t.type==="agent_run"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.runner")}),e.jsxs("select",{value:t.agentSlug,onChange:l=>g(t.key,{agentSlug:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.runnerPick")}),k.filter(l=>l.slug!=="muse").map(l=>e.jsx("option",{value:l.slug,children:l.name},l.slug))]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:t.prompt,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:l=>g(t.key,{prompt:l.target.value})})]})]}),(t.type==="db_row_add"||t.type==="db_row_edit")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:t.dbPath,onChange:l=>g(t.key,{dbPath:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(l=>e.jsx("option",{value:l,children:l},l)),t.dbPath&&!ee.includes(t.dbPath)&&e.jsx("option",{value:t.dbPath,children:t.dbPath})]})]}),t.type==="db_row_edit"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowId")}),e.jsx("input",{type:"text",value:t.rowId,placeholder:a(s==="db_changed"?"automation.builder.dbRowIdPh":"automation.builder.dbRowIdRequired"),onChange:l=>g(t.key,{rowId:l.target.value})})]}),t.type==="db_row_edit"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowFrom")}),e.jsx("input",{type:"text",value:t.rowFrom,maxLength:200,placeholder:a("automation.builder.dbRowFromPh"),onChange:l=>g(t.key,{rowFrom:l.target.value})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbMatch")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:t.matchColumn,maxLength:200,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:l=>g(t.key,{matchColumn:l.target.value})}),e.jsx("input",{type:"text",value:t.matchValue,maxLength:2e3,placeholder:a("automation.builder.dbMatchValPh"),onChange:l=>g(t.key,{matchValue:l.target.value})})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbTargetHint")})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbCells")}),t.cells.map((l,u)=>e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:l.k,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:M=>g(t.key,{cells:t.cells.map((N,T)=>T===u?{...N,k:M.target.value}:N)})}),e.jsx("input",{type:"text",value:l.v,placeholder:a(u===0?"automation.builder.dbCellValPh":"automation.builder.dbCellVal"),onChange:M=>g(t.key,{cells:t.cells.map((N,T)=>T===u?{...N,v:M.target.value}:N)})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),disabled:t.cells.length<=1,onClick:()=>g(t.key,{cells:t.cells.filter((M,N)=>N!==u)}),children:e.jsx(pe,{size:12})})]},u)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbCellAdd"),onClick:()=>g(t.key,{cells:[...t.cells,{k:"",v:""}]}),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbCellsHint")})]}),t.type==="db_row_add"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbSkipIfEmpty")}),e.jsx("input",{type:"text",value:t.skipIfEmpty,maxLength:200,placeholder:a("automation.builder.dbSkipIfEmptyPh"),onChange:l=>g(t.key,{skipIfEmpty:l.target.value})})]})]}),t.type==="tool_call"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.tool")}),e.jsxs("select",{value:t.tool,onChange:l=>{const u=f.find(N=>N.name===l.target.value),M=Object.fromEntries((u?.parameters.required||[]).filter(N=>u?.parameters.properties?.[N]?.type==="boolean").map(N=>[N,"false"]));g(t.key,{tool:l.target.value,argValues:M})},children:[e.jsx("option",{value:"",children:a("automation.builder.toolPick")}),f.map(l=>e.jsxs("option",{value:l.name,children:[l.name,l.dangerous?" ⚠":""]},l.name))]}),r&&e.jsxs("div",{className:"auto-hint",children:[r.description,r.dangerous?` · ${a("automation.builder.dangerous")}`:""]})]}),r&&Object.entries(r.parameters.properties||{}).map(([l,u])=>{const M=(r.parameters.required||[]).includes(l),N=`${l}${M?" *":""}`,T=t.argValues[l]||"",G=_=>g(t.key,{argValues:{...t.argValues,[l]:_}});return e.jsxs("div",{className:"field",children:[e.jsx("label",{title:u.description||"",children:N}),u.enum?.length?e.jsxs("select",{value:T,onChange:_=>G(_.target.value),children:[e.jsx("option",{value:""}),u.enum.map(_=>e.jsx("option",{value:_,children:_},_))]}):u.type==="boolean"?e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:T==="true",onChange:_=>G(_.target.checked?"true":"false")})," ",u.description||""]}):u.type==="number"?e.jsx("input",{type:"number",value:T,onChange:_=>G(_.target.value)}):u.type==="string"?e.jsx("textarea",{rows:2,value:T,placeholder:u.description||"",onChange:_=>G(_.target.value)}):e.jsx("textarea",{rows:2,value:T,placeholder:`JSON — ${u.description||""}`,onChange:_=>G(_.target.value)})]},l)})]})]},t.key)}),S.length===0&&i&&s!=="manual"&&e.jsxs("div",{className:"auto-node auto-node-muse",hidden:F!=="muse",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(Te,{size:14})}),a("automation.builder.museFallback")]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.museFallbackHint")}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:me,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:t=>Ue(t.target.value)})]})]}),e.jsxs("div",{className:"auto-node auto-review",hidden:F!=="review",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx(be,{size:16}),a("automation.ux.review")]}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.enableHint")}),e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:t=>A(t.target.checked)}),a("automation.ux.enabledLabel")]}),E.length?e.jsxs("div",{className:"auto-validation",role:"status",children:[e.jsx("strong",{children:a("automation.ux.checklist")}),E.map((t,d)=>e.jsx("button",{onClick:()=>x(t.node),children:t.text},d))]}):e.jsxs("p",{className:"auto-ready",children:[e.jsx(be,{size:14}),a("automation.ux.allReady")]}),s!=="timer"&&s!=="manual"&&e.jsxs("div",{className:"auto-guard",children:[e.jsx("label",{children:a("automation.builder.cooldown")}),e.jsx("input",{type:"number",value:K,min:Se?1:s==="db_changed"?0:.25,step:"1",onChange:t=>{Ce.current=!0,_e(t.target.value)}}),e.jsx("span",{className:"auto-hint",children:a(Se?"automation.builder.cooldownAgentHint":s==="db_changed"?"automation.builder.cooldownDbHint":"automation.builder.cooldownHint")})]})]}),e.jsxs("div",{className:"auto-node",hidden:F!=="help",children:[e.jsx("h3",{children:a("automation.ux.flow")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.canvasOrder")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.nativeHint")})]})]})]}),e.jsxs("div",{className:"auto-builder-actions auto-builder-footer",children:[e.jsx("div",{className:"auto-save-status","aria-live":"polite",children:we?e.jsx("span",{role:"alert",children:we}):E.length?e.jsxs("button",{onClick:()=>x(E[0].node),children:[E[0].text,E.length>1?` (+${E.length-1})`:""]}):e.jsx("span",{children:a("automation.ux.allReady")})}),e.jsx("button",{className:"btn ghost sm",onClick:()=>x("review"),children:a("automation.ux.review")}),e.jsx("button",{className:"btn sm",disabled:!ne||Y,onClick:()=>{Ye()},children:Y?"…":a(D?"automation.ux.saveEnabled":"automation.ux.savePaused")})]})]})},ra=Object.freeze(Object.defineProperty({__proto__:null,AutomationBuilder:Xt,hasUnsupportedParts:Ie},Symbol.toStringTag,{value:"Module"}));export{Ot as A,Lt as C,oa as S,Xt as a,ra as b};
1
+ import{r as o,j as e,u as pe}from"./index-YuejkHoJ.js";import{os as le,aW as Ze,jw as Je,js as Qe,ir as et,jz as tt,ot as at,g as nt,ab as it,ou as lt,ov as $e,ow as Ae,dg as Fe,ox as De,ha as be,oy as st,aQ as xe,oz as ot,oA as rt,aO as ut,aP as dt,D as ct,W as mt,ik as ht,oB as bt,oC as xt,oD as pt,oE as vt,u as jt}from"./appStore-BskcSDl6.js";import{p as gt,T as ft,b7 as yt,bv as Nt,aj as _t,ba as Ct,b9 as kt,u as wt,Z as Re,q as ze,a6 as St,am as Et,B as Pt,D as $t,as as Ft}from"./pageStore-D_fKLv-o.js";import{u as ie,h as Dt}from"./dbStore-Bc2lC8ZI.js";import{C as Rt}from"./CapabilityMenu-Dzn6RbB1.js";import{u as zt}from"./gestures-Bx9M0le5.js";import{a as Tt,C as Mt}from"./Chrome-owLewFu4.js";import{d as At,e as It,f as qt,g as Ht}from"./canvasPrefs-CMulOS0k.js";import{R as Wt}from"./rotate-ccw-CyZpL7MX.js";import"./messages-CG7ywZ-K.js";const Vt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Lt=gt("circle-question-mark",Vt);function Ot({controller:i,open:c,title:b,onClose:C,children:h}){const[j]=o.useState(()=>document.createElement("div"));j.className="auto-extension";const a=o.useRef(null),k=o.useRef(C);k.current=C;const v=o.useRef(b);return v.current=b,o.useEffect(()=>{if(!(!i||!c)){try{a.current=i.open({id:"automation-context",title:()=>v.current,mount:f=>(f.appendChild(j),()=>j.remove()),onClose:()=>k.current()})}catch{k.current()}return()=>{a.current?.close(),a.current=null}}},[i,c,j]),c?i?ft.createPortal(h,j):e.jsx("div",{className:"auto-extension auto-extension-inline",children:h}):null}const oa=["reminder","briefing","table","button"];function Bt(i,c){return i?i==="briefing"||i==="button"?[{...le("agent_run"),prompt:c(`automation.ux.${i}.prompt`)}]:[{...le("notify"),title:c(`automation.ux.${i}.name`),body:c(`automation.ux.${i}.body`)}]:[le("notify")]}function Te(i,c,b){if(i.type==="notify")return i.title.trim()?null:"notify";if(i.type==="agent_run")return i.agentSlug?i.prompt.trim()?null:"prompt":"agent";if(i.type==="db_row_add"||i.type==="db_row_edit"){if(!/\.db$/i.test(i.dbPath.trim()))return"table";if(!i.cells.some(h=>h.k.trim()))return"cells";if(i.type==="db_row_edit"){if(c!=="db_changed"&&(!i.rowId.trim()&&!i.matchColumn.trim()||i.rowFrom.trim()))return"row";if(i.matchColumn.trim()&&!i.matchValue.trim())return"match"}return null}const C=b.find(h=>h.name===i.tool);if(!C)return"tool";if((C.parameters.required||[]).some(h=>!(i.argValues[h]||"").trim()))return"args";for(const[h,j]of Object.entries(i.argValues)){if(!j.trim())continue;const a=C.parameters.properties?.[h];if(a?.type==="number"&&!Number.isFinite(Number(j)))return"args";if(a?.type==="object"||a?.type==="array")try{const k=JSON.parse(j);if(a.type==="array"?!Array.isArray(k):!k||typeof k!="object"||Array.isArray(k))return"json"}catch{return"json"}}return null}function Ut(i){return(i||[]).map(c=>({value:`{{row.${c.id}}}`,label:c.name}))}const Kt=i=>({x:0,y:i*132,w:244,h:84}),Gt=({nodes:i,selected:c,onSelect:b,children:C})=>{const{t:h}=pe(),j=o.useId().replace(/:/g,""),a=o.useRef(null),[k,v]=o.useState({}),[f,$]=o.useState(At),[A,F]=o.useState(It),x=yt(a),m=new Map(i.map((n,s)=>[n.id,k[n.id]||Kt(s)])),P=i.map(n=>n.id).join(","),p=zt(a,x,{boxes:()=>m,identity:()=>P,commit:n=>v(s=>({...s,...Object.fromEntries(n)})),hitKey:n=>n.closest("[data-flow-node]")?.dataset.flowNode||null,onEnterEdit:b,onDoubleClick:n=>{n&&b(n)},minW:244,minH:84,repel:!0},f);o.useEffect(()=>p.bind(a.current),[p.bind]),o.useEffect(()=>x.bindWheel(a.current),[x.bindWheel]);const R=o.useRef(()=>x.fitTo([...m.values()],64));R.current=()=>x.fitTo([...m.values()],64),o.useEffect(()=>{v({});const n=requestAnimationFrame(()=>R.current());return()=>cancelAnimationFrame(n)},[P]),o.useEffect(()=>{const n=new ResizeObserver(()=>R.current());return a.current&&n.observe(a.current),()=>n.disconnect()},[]);const I=n=>p.live?.get(n)||m.get(n);return e.jsx("div",{className:"auto-canvas-shell am-app",children:e.jsxs("div",{className:"auto-canvas amx-stage",ref:a,tabIndex:0,"aria-label":h("automation.ux.flow"),onPointerUpCapture:n=>{if(p.busy)return;const s=document.elementFromPoint(n.clientX,n.clientY)?.closest("[data-flow-node]");s&&a.current?.contains(s)&&b(s.dataset.flowNode)},children:[e.jsx("div",{className:"amx-stage-grid",style:Nt(x.vp)}),e.jsxs("div",{className:"auto-canvas-world",style:{transform:`translate(${x.vp.x}px, ${x.vp.y}px) scale(${x.vp.z})`},children:[e.jsxs("svg",{className:"auto-canvas-edges","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsx("marker",{id:j,markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:e.jsx("path",{d:"M0,0 L6,3 L0,6",fill:"none",stroke:"currentColor"})})}),i.slice(1).map((n,s)=>{const y=I(i[s].id),w=I(n.id),q=y.x+y.w/2,H=y.y+y.h,Y=w.x+w.w/2,V=w.y;return e.jsx("path",{d:`M${q},${H} C${q},${H+28} ${Y},${V-28} ${Y},${V}`,markerEnd:`url(#${j})`},n.id)})]}),i.map(n=>{const s=I(n.id);return e.jsxs("div",{"data-flow-node":n.id,role:"button",tabIndex:0,"aria-pressed":c===n.id,className:`auto-flow-node ${c===n.id?"selected":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},onClick:()=>b(n.id),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),b(n.id))},children:[e.jsx("span",{className:"auto-flow-icon",children:n.icon}),e.jsx("strong",{children:n.title}),e.jsx("span",{className:"auto-flow-status",title:h(n.ready?"automation.ux.ready":"automation.ux.incomplete"),children:n.ready?e.jsx(_t,{size:13}):e.jsx(Ze,{size:13})}),e.jsx("span",{className:"auto-flow-subtitle",children:n.subtitle})]},n.id)}),p.marquee&&e.jsx("div",{className:"amx-stage-marquee",style:{left:p.marquee.x,top:p.marquee.y,width:p.marquee.w,height:p.marquee.h}})]}),C&&e.jsx("div",{className:"amx-stage-tools auto-canvas-tools",children:C}),e.jsx(Tt,{zoom:x.vp.z,onZoomBy:n=>{const{w:s,h:y}=Ct(a.current);x.setVp(kt(x.vp,x.vp.z*n,s/2,y/2))},onFit:()=>R.current(),snap:f,onSnap:n=>{$(n),Ht(n)},mini:A,onMini:n=>{F(n),qt(n)},extra:e.jsx("button",{type:"button",title:h("automation.ux.arrange"),onClick:()=>{v({}),requestAnimationFrame(()=>R.current())},children:e.jsx(Wt,{size:12})})}),A&&e.jsx(Mt,{hostRef:a,vp:x.vp,items:i.map(n=>({key:n.id,kind:"card",box:I(n.id)})),onCenter:x.centerOn})]})})},Me=({label:i,value:c,onChange:b,multiline:C,maxLength:h=4e3,placeholder:j,columns:a,hasRow:k})=>{const{t:v}=pe(),f=o.useId(),$=o.useRef(null),A=o.useRef({start:c.length,end:c.length}),F=m=>{if(!m)return;const{start:P,end:p}=A.current;c.length-(p-P)+m.length>h||(b(c.slice(0,P)+m+c.slice(p)),requestAnimationFrame(()=>{$.current?.focus(),$.current?.setSelectionRange(P+m.length,P+m.length)}))},x={id:f,ref:$,value:c,maxLength:h,placeholder:j,onChange:m=>b(m.target.value),onSelect:m=>{A.current={start:m.currentTarget.selectionStart??c.length,end:m.currentTarget.selectionEnd??c.length}}};return e.jsxs("div",{className:"field auto-template-field",children:[e.jsxs("div",{className:"auto-field-heading",children:[e.jsx("label",{htmlFor:f,children:i}),e.jsxs("select",{"aria-label":v("automation.ux.insertVariable",{field:i}),value:"",onChange:m=>F(m.target.value),children:[e.jsx("option",{value:"",children:v("automation.ux.variables")}),e.jsx("option",{value:"{{today}}",children:v("automation.ux.today")}),e.jsx("option",{value:"{{now}}",children:v("automation.ux.now")}),k&&e.jsxs("optgroup",{label:v("automation.ux.triggerRow"),children:[e.jsx("option",{value:"{{row.id}}",children:v("automation.ux.rowId")}),Ut(a).map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))]})]})]}),C?e.jsx("textarea",{...x}):e.jsx("input",{type:"text",...x})]})};function Xt(){const i=new Date(Date.now()+36e5);i.setMinutes(0,0,0);const c=b=>String(b).padStart(2,"0");return`${i.getFullYear()}-${c(i.getMonth()+1)}-${c(i.getDate())}T${c(i.getHours())}:00`}const Yt=({editing:i,starter:c,fixedManual:b,onSaved:C,onCancel:h,extendView:j})=>{const{t:a}=pe(),k=Je(),v=Qe(),f=v.actionsCatalog,[$,A]=o.useState(i?.desc||(c?a(`automation.ux.${c}.name`):"")),[F,x]=o.useState("trigger"),[m,P]=o.useState(!1),p=t=>{x(t),P(!0)},[R,I]=o.useState(i?.enabled??!!b),n=i?.cond,[s,y]=o.useState(n?n.type==="event_seen"?"event_seen":n.type==="file_chars_gte"?"file_chars_gte":n.type==="manual"?"manual":n.type==="db_changed"?"db_changed":"timer":b||c==="button"?"manual":c==="table"?"db_changed":"timer"),[w,q]=o.useState(n?.type==="at"?"at":n?.type==="every"?"every":"daily_at"),[H,Y]=o.useState(n?.type==="daily_at"?n.time:"09:00"),V=!!i&&et(i),[Z,Ie]=o.useState(n?.type==="at"&&!V?n.datetime.replace(" ","T"):Xt()),J=n?.type==="every"?/^(\d+)([mhd])$/.exec(n.interval):null,[Q,qe]=o.useState(J?J[1]:"1"),[ve,He]=o.useState(J?J[2]:"h"),[se,We]=o.useState(n?.type==="event_seen"?n.match:""),[oe,Ve]=o.useState(n?.type==="file_chars_gte"?n.path:""),[re,Le]=o.useState(n?.type==="file_chars_gte"?String(n.n):"100"),[D,Oe]=o.useState(n?.type==="db_changed"?n.path:""),[T,je]=o.useState(n?.type==="db_changed"?n.event:"row_added"),[W,ge]=o.useState(()=>tt(n)),fe=(t,d)=>ge(r=>d?r.includes(t)?r:[...r,t]:r.filter(l=>l!==t)),[ue,Be]=o.useState(n?.type==="db_changed"&&n.equals||""),[L,de]=o.useState(()=>at(n)),ce=(t,d)=>de(r=>r.map((l,u)=>u===t?{...l,...d}:l));o.useEffect(()=>{nt()},[]);const ye=wt(t=>t.files),O=o.useMemo(()=>ye.filter(t=>/\.db$/i.test(t)),[ye]);o.useEffect(()=>{for(const t of O)ie.getState().load(t,t)},[O]);const Ne=ie(it(t=>O.filter(d=>t.entries[d]?.data?.source!==void 0))),ee=o.useMemo(()=>O.filter(t=>!Ne.includes(t)),[O,Ne]),B=ie(t=>s==="db_changed"&&D?t.entries[D]?.data?.columns:void 0),U=o.useMemo(()=>B?.filter(t=>t.type!=="formula"&&t.type!=="lookup"),[B]),[S,te]=o.useState(()=>i?lt(i):Bt(c,a)),[me,Ue]=o.useState(i&&!i.actions?.length&&!i.agentSlug&&i.prompt||""),[K,_e]=o.useState(()=>$e(i,s)),Ce=o.useRef(!1);o.useEffect(()=>{!i&&!Ce.current&&_e($e(null,s))},[s,i]);const[G,ke]=o.useState(!1),[we,ae]=o.useState(""),Ke=t=>{if(S.length>=24)return;const d=le(t);te(r=>[...r,d]),p(String(d.key))},Se=S.some(t=>t.type==="agent_run"),g=(t,d)=>te(r=>r.map(l=>l.key===t?{...l,...d}:l)),Ee=(t,d)=>te(r=>{const l=t+d;if(l<0||l>=r.length)return r;const u=[...r];return[u[t],u[l]]=[u[l],u[t]],u});if(Ae(i))return e.jsxs("div",{className:"auto-builder",children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(Fe,{size:17})," ",a("automation.builder.editTitle")]}),e.jsx("div",{className:"auto-node",children:e.jsx("div",{className:"auto-hint",children:a("automation.builder.unsupported")})}),e.jsx("div",{className:"auto-builder-actions",children:e.jsx("button",{className:"btn ghost",onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})})]});const Pe=!(s==="timer"&&(w==="daily_at"&&!/^\d{1,2}:\d{2}$/.test(H)||w==="at"&&!Z||w==="every"&&(!Number.isInteger(Number(Q))||Number(Q)<1))||s==="event_seen"&&!se.trim()||s==="file_chars_gte"&&(!oe.trim()||!(Number(re)>0))||s==="db_changed"&&(!/\.db$/i.test(D.trim())||T==="cell_changed"&&!W.length||L.length>De||L.some(t=>t.column.trim()&&(t.op==="eq"||t.op==="ne")&&!t.value.trim()))),E=[];$.trim()||E.push({node:"trigger",text:a("automation.ux.issue.name")}),Pe||E.push({node:"trigger",text:a("automation.ux.issue.trigger")}),!S.length&&(!i||s==="manual")&&E.push({node:"review",text:a("automation.ux.issue.steps")}),S.forEach((t,d)=>{const r=Te(t,s,f);r&&E.push({node:String(t.key),text:`${d+1}. ${a(`automation.ux.issue.${r}`)}`})}),s!=="timer"&&s!=="manual"&&(!K.trim()||!Number.isFinite(Number(K))||Number(K)<0)&&E.push({node:"review",text:a("automation.ux.issue.cooldown")});const ne=E.length===0,Ge=async()=>{if(!ne||G)return;const t=s==="timer"?w:s;if(t==="at"&&(ht(Z)?.getTime()??0)<Date.now()-5*6e4){ae(a("automation.builder.atPast"));return}const d=u=>ie.getState().entries[u]?.data?.source!==void 0;if([...t==="db_changed"?[D.trim()]:[],...S.filter(u=>u.type==="db_row_add"||u.type==="db_row_edit").map(u=>u.dbPath.trim())].filter(Boolean).some(d)){ae(a("automation.builder.dbNoteView"));return}ke(!0),ae("");const l=bt(S,f);try{const u=await xt(Dt(),{id:i?.id,actor:"user",desc:$.trim(),cond_type:t,time:t==="daily_at"?H:void 0,datetime:t==="at"?Z:void 0,interval:t==="every"?`${Math.floor(Number(Q))}${ve}`:void 0,match:t==="event_seen"?se.trim():void 0,path:t==="file_chars_gte"?oe.trim():t==="db_changed"?D.trim():void 0,n:t==="file_chars_gte"?Number(re):void 0,event:t==="db_changed"?T:void 0,column_id:t==="db_changed"&&T==="cell_changed"?W[0]:void 0,column_ids:t==="db_changed"&&T==="cell_changed"&&W.length>1?W:void 0,equals:t==="db_changed"&&T==="cell_changed"&&ue.trim()?ue.trim():void 0,where:t==="db_changed"?vt(L):void 0,vault:t==="db_changed"&&i?.cond.type==="db_changed"?i.cond.vault:void 0,prompt:S.length?void 0:me.trim()||void 0,cooldown_hours:pt(s,K),actions:S.length?l:null,enabled:R});if(i?.id||Ft("automation.create"),C){v.bump(),C(u);return}v.acceptSaved(u),jt.getState().toast(a("automation.ux.saved"))}catch(u){ae(String(u?.message||u))}finally{ke(!1)}},he=t=>t==="notify"?e.jsx(ct,{size:14}):t==="agent_run"?e.jsx(Pt,{size:14}):t==="db_row_add"||t==="db_row_edit"?e.jsx($t,{size:14}):e.jsx(mt,{size:14}),Xe=[{id:"trigger",title:a("automation.builder.trigger"),subtitle:a(`automation.builder.${s==="timer"?"condTimer":s==="manual"?"condManual":s==="db_changed"?"condDb":s==="event_seen"?"condEvent":"condFile"}`),icon:e.jsx(Re,{size:17}),ready:Pe&&!!$.trim()},...S.map((t,d)=>({id:String(t.key),title:`${d+1}. ${a(`automation.step.${t.type}`)}`,subtitle:t.title||t.prompt||t.dbPath||t.tool||a("automation.ux.setupHint"),icon:he(t.type),ready:!Te(t,s,f)})),...!S.length&&i&&s!=="manual"?[{id:"muse",title:a("automation.builder.museFallback"),subtitle:me||a("automation.builder.museFallbackHint"),icon:e.jsx(ze,{size:17}),ready:!0}]:[],{id:"review",title:a("automation.ux.finish"),subtitle:a(ne?"automation.ux.allReady":"automation.ux.finishHint"),icon:e.jsx(be,{size:17}),ready:ne}],Ye=e.jsxs(e.Fragment,{children:[e.jsxs(Rt,{label:a("automation.ux.addStep"),className:"btn ghost sm",disabled:G||S.length>=24,items:["notify","agent_run","db_row_add","db_row_edit","tool_call"].map(t=>({id:t,label:a(`automation.step.${t}`),icon:he(t),disabled:t==="tool_call"&&!f.length,onSelect:()=>Ke(t)})),children:[e.jsx(St,{size:14}),a("automation.ux.addStep")]}),e.jsx("button",{className:"icon-btn",title:a("automation.ux.help"),onClick:()=>p("help"),children:e.jsx(Lt,{size:15})})]});return e.jsxs("div",{className:`auto-builder auto-workflow-builder ${b?"auto-builder-embedded":""}`,children:[e.jsxs("div",{className:"auto-builder-title",children:[e.jsx(Fe,{size:17}),e.jsx("span",{children:a(i?"automation.builder.editTitle":"automation.builder.title")}),e.jsx("button",{className:"btn ghost sm",disabled:G,onClick:()=>h?h():v.closeBuilder(),children:a("common.cancel")})]}),e.jsx("div",{className:"auto-builder-workspace",hidden:!j&&m,children:e.jsx(Gt,{nodes:Xe,selected:m?F:"",onSelect:p,children:Ye})}),e.jsxs(Ot,{controller:j,open:m,title:a("automation.ux.setup"),onClose:()=>P(!1),children:[!j&&e.jsxs("button",{className:"btn ghost sm auto-inline-back",onClick:()=>P(!1),children:[e.jsx(Et,{size:14}),a("automation.ux.flow")]}),e.jsxs("div",{className:"auto-inspector","aria-label":a("automation.ux.setup"),children:[e.jsxs("div",{className:"auto-node",hidden:F!=="trigger",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(Re,{size:14})}),a("automation.builder.trigger")]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.desc")}),e.jsx("input",{"aria-label":a("automation.builder.desc"),type:"text",value:$,maxLength:200,placeholder:a("automation.builder.descPh"),onChange:t=>A(t.target.value)})]}),!b&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.condType")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:s==="timer"?"active":"",onClick:()=>y("timer"),children:a("automation.builder.condTimer")}),e.jsx("button",{className:s==="event_seen"?"active":"",onClick:()=>y("event_seen"),children:a("automation.builder.condEvent")}),e.jsx("button",{className:s==="file_chars_gte"?"active":"",onClick:()=>y("file_chars_gte"),children:a("automation.builder.condFile")}),e.jsx("button",{className:s==="db_changed"?"active":"",onClick:()=>y("db_changed"),children:a("automation.builder.condDb")}),e.jsx("button",{className:s==="manual"?"active":"",onClick:()=>y("manual"),children:a("automation.builder.condManual")})]})]}),s==="db_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:D,onChange:t=>{Oe(t.target.value),ge([])},children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(t=>e.jsx("option",{value:t,children:t},t)),D&&!ee.includes(D)&&e.jsx("option",{value:D,children:D})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEvent")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:T==="row_added"?"active":"",onClick:()=>je("row_added"),children:a("automation.builder.dbEventRow")}),e.jsx("button",{className:T==="cell_changed"?"active":"",onClick:()=>je("cell_changed"),children:a("automation.builder.dbEventCell")})]})]}),T==="cell_changed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbColumn")}),e.jsxs("div",{className:"auto-checks",children:[(U??[]).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:W.includes(t.id),onChange:d=>fe(t.id,d.target.checked)}),t.name]},t.id)),W.filter(t=>!(U??[]).some(d=>d.id===t)).map(t=>e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:!0,onChange:()=>fe(t,!1)}),"(",t,")"]},t)),!U&&e.jsx("span",{className:"auto-hint",children:a("automation.builder.dbColsLoading")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbColumnsHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbEquals")}),e.jsx("input",{type:"text",value:ue,maxLength:200,placeholder:a("automation.builder.dbEqualsPh"),onChange:t=>Be(t.target.value)})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbWhere")}),L.map((t,d)=>e.jsxs("div",{className:"auto-inline",children:[e.jsxs("select",{value:t.column,onChange:r=>ce(d,{column:r.target.value}),children:[e.jsx("option",{value:"",children:a(B?"automation.builder.dbPickCol":"automation.builder.dbColsLoading")}),(B??[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id)),t.column&&!(B??[]).some(r=>r.id===t.column)&&e.jsxs("option",{value:t.column,children:["(",t.column,")"]})]}),e.jsx("select",{value:t.op,onChange:r=>ce(d,{op:r.target.value}),children:st.map(r=>e.jsx("option",{value:r,children:a(r==="eq"?"automation.builder.dbWhereOpEq":r==="ne"?"automation.builder.dbWhereOpNe":r==="empty"?"automation.builder.dbWhereOpEmpty":"automation.builder.dbWhereOpNotEmpty")},r))}),e.jsx("input",{type:"text",value:t.value,maxLength:200,disabled:t.op==="empty"||t.op==="notempty",placeholder:a("automation.builder.dbWhereValPh"),onChange:r=>ce(d,{value:r.target.value})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>de(r=>r.filter((l,u)=>u!==d)),children:e.jsx(xe,{size:12})})]},d)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbWhereAdd"),disabled:L.length>=De,onClick:()=>de(t=>[...t,{column:"",op:"eq",value:""}]),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbWhereHint")})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbHint")})]}),s==="manual"&&e.jsx("div",{className:"auto-hint",children:a("automation.builder.manualHint")}),s==="timer"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.timerMode")}),e.jsxs("div",{className:"auto-seg",children:[e.jsx("button",{className:w==="daily_at"?"active":"",onClick:()=>q("daily_at"),children:a("automation.builder.timerDaily")}),e.jsx("button",{className:w==="at"?"active":"",onClick:()=>q("at"),children:a("automation.builder.timerOnce")}),e.jsx("button",{className:w==="every"?"active":"",onClick:()=>q("every"),children:a("automation.builder.timerEvery")})]})]}),w==="daily_at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.time")}),e.jsx("input",{type:"time",value:H,onChange:t=>Y(t.target.value)})]}),w==="at"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.datetime")}),e.jsx("input",{type:"datetime-local",value:Z,onChange:t=>Ie(t.target.value)}),e.jsx("div",{className:"auto-hint",children:a(V?"automation.builder.expiredReset":"automation.builder.onceHint")})]}),w==="every"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.interval")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"number",value:Q,min:1,style:{width:90},onChange:t=>qe(t.target.value)}),e.jsxs("select",{value:ve,onChange:t=>He(t.target.value),children:[e.jsx("option",{value:"m",children:a("automation.builder.unitM")}),e.jsx("option",{value:"h",children:a("automation.builder.unitH")}),e.jsx("option",{value:"d",children:a("automation.builder.unitD")})]})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.everyHint")})]})]}),s==="event_seen"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.match")}),e.jsx("input",{type:"text",list:"auto-event-catalog",value:se,maxLength:120,placeholder:a("automation.builder.matchPh"),onChange:t=>We(t.target.value)}),e.jsxs("datalist",{id:"auto-event-catalog",children:[ot.map(t=>e.jsx("option",{value:t},t)),rt().map(t=>e.jsx("option",{value:t.name,label:t.label},t.name))]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.matchHint")})]}),s==="file_chars_gte"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.path")}),e.jsx("input",{type:"text",value:oe,placeholder:"~/Forsion/Notes/xxx.md",onChange:t=>Ve(t.target.value)})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.chars")}),e.jsx("input",{type:"number",value:re,min:1,onChange:t=>Le(t.target.value)})]})]})]}),S.map((t,d)=>{const r=t.type==="tool_call"?f.find(l=>l.name===t.tool):void 0;return e.jsxs("div",{className:"auto-node",hidden:F!==String(t.key),children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:he(t.type)}),a("automation.builder.stepN",{n:String(d+1)})," · ",a(`automation.step.${t.type}`),e.jsxs("span",{className:"auto-step-tools",children:[e.jsx("button",{className:"icon-btn",disabled:d===0,title:a("automation.builder.moveUp"),onClick:()=>Ee(d,-1),children:e.jsx(ut,{size:12})}),e.jsx("button",{className:"icon-btn",disabled:d===S.length-1,title:a("automation.builder.moveDown"),onClick:()=>Ee(d,1),children:e.jsx(dt,{size:12})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),onClick:()=>{te(l=>l.filter(u=>u.key!==t.key)),p("trigger")},children:e.jsx(xe,{size:12})})]})]}),t.type==="notify"&&e.jsxs(e.Fragment,{children:[e.jsx(Me,{label:a("automation.builder.notifyTitle"),value:t.title,maxLength:200,placeholder:a("automation.builder.notifyTitlePh"),onChange:l=>g(t.key,{title:l}),columns:U,hasRow:s==="db_changed"}),e.jsx(Me,{label:a("automation.builder.notifyBody"),value:t.body,multiline:!0,onChange:l=>g(t.key,{body:l}),columns:U,hasRow:s==="db_changed"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.notifyHint")})]}),t.type==="agent_run"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.runner")}),e.jsxs("select",{value:t.agentSlug,onChange:l=>g(t.key,{agentSlug:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.runnerPick")}),k.filter(l=>l.slug!=="muse").map(l=>e.jsx("option",{value:l.slug,children:l.name},l.slug))]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:t.prompt,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:l=>g(t.key,{prompt:l.target.value})})]})]}),(t.type==="db_row_add"||t.type==="db_row_edit")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbPath")}),e.jsxs("select",{value:t.dbPath,onChange:l=>g(t.key,{dbPath:l.target.value}),children:[e.jsx("option",{value:"",children:a("automation.builder.dbPickDb")}),ee.map(l=>e.jsx("option",{value:l,children:l},l)),t.dbPath&&!ee.includes(t.dbPath)&&e.jsx("option",{value:t.dbPath,children:t.dbPath})]})]}),t.type==="db_row_edit"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowId")}),e.jsx("input",{type:"text",value:t.rowId,placeholder:a(s==="db_changed"?"automation.builder.dbRowIdPh":"automation.builder.dbRowIdRequired"),onChange:l=>g(t.key,{rowId:l.target.value})})]}),t.type==="db_row_edit"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbRowFrom")}),e.jsx("input",{type:"text",value:t.rowFrom,maxLength:200,placeholder:a("automation.builder.dbRowFromPh"),onChange:l=>g(t.key,{rowFrom:l.target.value})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbMatch")}),e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:t.matchColumn,maxLength:200,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:l=>g(t.key,{matchColumn:l.target.value})}),e.jsx("input",{type:"text",value:t.matchValue,maxLength:2e3,placeholder:a("automation.builder.dbMatchValPh"),onChange:l=>g(t.key,{matchValue:l.target.value})})]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbTargetHint")})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbCells")}),t.cells.map((l,u)=>e.jsxs("div",{className:"auto-inline",children:[e.jsx("input",{type:"text",value:l.k,placeholder:a("automation.builder.dbCellKey"),style:{width:120},onChange:M=>g(t.key,{cells:t.cells.map((N,z)=>z===u?{...N,k:M.target.value}:N)})}),e.jsx("input",{type:"text",value:l.v,placeholder:a(u===0?"automation.builder.dbCellValPh":"automation.builder.dbCellVal"),onChange:M=>g(t.key,{cells:t.cells.map((N,z)=>z===u?{...N,v:M.target.value}:N)})}),e.jsx("button",{className:"icon-btn",title:a("common.delete"),disabled:t.cells.length<=1,onClick:()=>g(t.key,{cells:t.cells.filter((M,N)=>N!==u)}),children:e.jsx(xe,{size:12})})]},u)),e.jsx("button",{className:"icon-btn",title:a("automation.builder.dbCellAdd"),onClick:()=>g(t.key,{cells:[...t.cells,{k:"",v:""}]}),children:"+"}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.dbCellsHint")})]}),t.type==="db_row_add"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.dbSkipIfEmpty")}),e.jsx("input",{type:"text",value:t.skipIfEmpty,maxLength:200,placeholder:a("automation.builder.dbSkipIfEmptyPh"),onChange:l=>g(t.key,{skipIfEmpty:l.target.value})})]})]}),t.type==="tool_call"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.tool")}),e.jsxs("select",{value:t.tool,onChange:l=>{const u=f.find(N=>N.name===l.target.value),M=Object.fromEntries((u?.parameters.required||[]).filter(N=>u?.parameters.properties?.[N]?.type==="boolean").map(N=>[N,"false"]));g(t.key,{tool:l.target.value,argValues:M})},children:[e.jsx("option",{value:"",children:a("automation.builder.toolPick")}),f.map(l=>e.jsxs("option",{value:l.name,children:[l.name,l.dangerous?" ⚠":""]},l.name))]}),r&&e.jsxs("div",{className:"auto-hint",children:[r.description,r.dangerous?` · ${a("automation.builder.dangerous")}`:""]})]}),r&&Object.entries(r.parameters.properties||{}).map(([l,u])=>{const M=(r.parameters.required||[]).includes(l),N=`${l}${M?" *":""}`,z=t.argValues[l]||"",X=_=>g(t.key,{argValues:{...t.argValues,[l]:_}});return e.jsxs("div",{className:"field",children:[e.jsx("label",{title:u.description||"",children:N}),u.enum?.length?e.jsxs("select",{value:z,onChange:_=>X(_.target.value),children:[e.jsx("option",{value:""}),u.enum.map(_=>e.jsx("option",{value:_,children:_},_))]}):u.type==="boolean"?e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:z==="true",onChange:_=>X(_.target.checked?"true":"false")})," ",u.description||""]}):u.type==="number"?e.jsx("input",{type:"number",value:z,onChange:_=>X(_.target.value)}):u.type==="string"?e.jsx("textarea",{rows:2,value:z,placeholder:u.description||"",onChange:_=>X(_.target.value)}):e.jsx("textarea",{rows:2,value:z,placeholder:`JSON — ${u.description||""}`,onChange:_=>X(_.target.value)})]},l)})]})]},t.key)}),S.length===0&&i&&s!=="manual"&&e.jsxs("div",{className:"auto-node auto-node-muse",hidden:F!=="muse",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx("span",{className:"auto-ic",children:e.jsx(ze,{size:14})}),a("automation.builder.museFallback")]}),e.jsx("div",{className:"auto-hint",children:a("automation.builder.museFallbackHint")}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:a("automation.builder.prompt")}),e.jsx("textarea",{value:me,maxLength:500,placeholder:a("automation.builder.promptPh"),onChange:t=>Ue(t.target.value)})]})]}),e.jsxs("div",{className:"auto-node auto-review",hidden:F!=="review",children:[e.jsxs("div",{className:"auto-node-head",children:[e.jsx(be,{size:16}),a("automation.ux.review")]}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.enableHint")}),e.jsxs("label",{className:"auto-check",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:t=>I(t.target.checked)}),a("automation.ux.enabledLabel")]}),E.length?e.jsxs("div",{className:"auto-validation",role:"status",children:[e.jsx("strong",{children:a("automation.ux.checklist")}),E.map((t,d)=>e.jsx("button",{onClick:()=>p(t.node),children:t.text},d))]}):e.jsxs("p",{className:"auto-ready",children:[e.jsx(be,{size:14}),a("automation.ux.allReady")]}),s!=="timer"&&s!=="manual"&&e.jsxs("div",{className:"auto-guard",children:[e.jsx("label",{children:a("automation.builder.cooldown")}),e.jsx("input",{type:"number",value:K,min:Se?1:s==="db_changed"?0:.25,step:"1",onChange:t=>{Ce.current=!0,_e(t.target.value)}}),e.jsx("span",{className:"auto-hint",children:a(Se?"automation.builder.cooldownAgentHint":s==="db_changed"?"automation.builder.cooldownDbHint":"automation.builder.cooldownHint")})]})]}),e.jsxs("div",{className:"auto-node",hidden:F!=="help",children:[e.jsx("h3",{children:a("automation.ux.flow")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.canvasOrder")}),e.jsx("p",{className:"auto-hint",children:a("automation.ux.nativeHint")})]})]})]}),e.jsxs("div",{className:"auto-builder-actions auto-builder-footer",children:[e.jsx("div",{className:"auto-save-status","aria-live":"polite",children:we?e.jsx("span",{role:"alert",children:we}):E.length?e.jsxs("button",{onClick:()=>p(E[0].node),children:[E[0].text,E.length>1?` (+${E.length-1})`:""]}):e.jsx("span",{children:a("automation.ux.allReady")})}),e.jsx("button",{className:"btn ghost sm",onClick:()=>p("review"),children:a("automation.ux.review")}),e.jsx("button",{className:"btn sm",disabled:!ne||G,onClick:()=>{Ge()},children:G?"…":a(R?"automation.ux.saveEnabled":"automation.ux.savePaused")})]})]})},ra=Object.freeze(Object.defineProperty({__proto__:null,AutomationBuilder:Yt,hasUnsupportedParts:Ae},Symbol.toStringTag,{value:"Module"}));export{Ot as A,Lt as C,oa as S,Yt as a,ra as b};
@@ -1 +1 @@
1
- import{j as e,u as H,r as m,a as ea}from"./index-fDB1l4d-.js";import{l as sa,aH as na,aA as ta,u as ca,a6 as la,X as G,D as V}from"./pageStore-CyvNZEYX.js";import"./client-fKy9CWk0.js";import{A as oa}from"./astryxBridge-BL56QfEv.js";import{qA as ra,eT as _,qB as ia,qi as da,qp as ma,q_ as ua,qj as E,qM as ha,qy as fa,qD as ga,qk as pa,qr as xa,qs as ba,qt as ja,q$ as v,ql as y,qm as va,qo as Na,qH as Ca,G as wa,f9 as F,eH as Da,r0 as W,r1 as ya,r2 as U,r3 as Ma,r4 as ka,l0 as za,S as Sa}from"./appStore-DDOkzWDA.js";import{u as qa}from"./dbStore-BIG5Mfh2.js";import{u as I}from"./calendarNavStore-DCi7VBmM.js";import{U as Aa}from"./upload-Dy7svciS.js";import"./react-b7FrqRQR.js";import"./ipc-SAPDwyQ4.js";import"./nativeDownload-DsGyUSJ5.js";import"./drawingStore-CGvTqqYW.js";ea({"calcfg.prevMonth":{zh:"上个月",en:"Previous month"},"calcfg.nextMonth":{zh:"下个月",en:"Next month"},"calcfg.jumpToDay":{zh:"跳转到这一天",en:"Jump to this day"},"calcfg.title":{zh:"日历",en:"Calendars"},"calcfg.empty":{zh:"还没有加入日历的多维表。",en:"No databases added to the calendar yet."},"calcfg.eventColor":{zh:"事件颜色",en:"Event color"},"calcfg.fetchFailed":{zh:"拉取失败",en:"Fetch failed"},"calcfg.default":{zh:"默认",en:"Default"},"calcfg.defaultHint":{zh:"新建的事件落在这里",en:"New events go here"},"calcfg.showName":{zh:"在日历中显示「{name}」",en:"Show “{name}” in the calendar"},"calcfg.srcAgent":{zh:"Agent 日程(只读)",en:"Agent schedule (read-only)"},"calcfg.srcOther":{zh:"{side} 的日历(只读)",en:"Calendar from {side} (read-only)"},"calcfg.srcIcs":{zh:"外部日历(只读)",en:"External calendar (read-only)"},"calcfg.more":{zh:"更多",en:"More"},"calcfg.addCalendar":{zh:"添加日历",en:"Add calendar"},"calcfg.addDatabase":{zh:"添加多维表",en:"Add database"},"calcfg.subscribeExternal":{zh:"订阅外部日历",en:"Subscribe to external calendar"},"calcfg.subscribeHint":{zh:"粘贴 .ics 订阅地址(Google / Outlook / Apple 日历「密钥地址」都行)",en:"Paste an .ics subscription URL (Google, Outlook, or Apple Calendar's private address all work)"},"calcfg.importIcs":{zh:"导入 .ics 文件",en:"Import .ics file"},"calcfg.fileTooLarge":{zh:"文件过大(> {mb}MB)",en:"File too large (over {mb} MB)"},"calcfg.notIcs":{zh:"这不是一个 .ics 日历文件",en:"That isn't an .ics calendar file"},"calcfg.readFailed":{zh:"读取失败:{msg}",en:"Failed to read: {msg}"},"calcfg.renameCalendar":{zh:"重命名日历",en:"Rename calendar"},"calcfg.renameSub":{zh:"重命名订阅",en:"Rename subscription"},"calcfg.rename":{zh:"重命名",en:"Rename"},"calcfg.refreshNow":{zh:"立即刷新",en:"Refresh now"},"calcfg.unsubscribe":{zh:"取消订阅",en:"Unsubscribe"},"calcfg.setDefaultDb":{zh:"设为默认日历",en:"Set as default calendar"},"calcfg.openInNewTab":{zh:"在新标签打开",en:"Open in new tab"},"calcfg.columnMapping":{zh:"日期与完成列…",en:"Date and done columns…"},"calcfg.removeFromCalendar":{zh:"从日历移除",en:"Remove from calendar"},"calcfg.searchDbPlaceholder":{zh:"搜索要加入日历的多维表…",en:"Search databases to add to the calendar…"},"calcfg.noCandidates":{zh:"没有含日期属性的可添加多维表",en:"No databases with a date property available to add"},"calcfg.footHint":{zh:"只有含「日期」属性的多维表会出现在这里",en:"Only databases with a Date property appear here"}});function Wa(){return e.jsx(oa,{children:e.jsxs("div",{className:"amx-calside",children:[e.jsx(Ea,{}),e.jsx(Pa,{})]})})}const T=s=>new Date(s.getFullYear(),s.getMonth(),1);function Ea(){const{t:s}=H(),o=sa(n=>(n.mainTabs,((n.api?na(n.api):null)?.params??{}).__type==="calendar")),f=I(n=>n.visibleStart),g=I(n=>n.visibleEnd),N=I(n=>n.requestJump),x=m.useMemo(()=>ra(new Date),[]),[u,d]=m.useState(()=>T(x));m.useEffect(()=>{if(o&&f&&g){const n=_(f),i=ia(n,Math.floor(da(_(g),n)/2));d(T(i))}},[o,f,g]);const C=ma(),p=m.useMemo(()=>ua(u),[u,C]),w=E(x,!0),c=n=>{if(!o||!f||!g)return!1;const i=E(n,!0);return i>=f&&i<=g},M=n=>{d(T(n)),o&&N(E(n,!0))};return e.jsxs("div",{className:"amx-mini",children:[e.jsxs("div",{className:"amx-mini-head",children:[e.jsx("span",{className:"amx-mini-title",children:ha(u)}),e.jsx("button",{className:"amx-mini-nav",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()-1,1)),"aria-label":s("calcfg.prevMonth"),children:e.jsx(fa,{size:14})}),e.jsx("button",{className:"amx-mini-nav",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()+1,1)),"aria-label":s("calcfg.nextMonth"),children:e.jsx(ta,{size:14})})]}),e.jsx("div",{className:"amx-mini-dow",children:ga().map(n=>e.jsx("span",{children:n},n))}),e.jsx("div",{className:"amx-mini-grid",children:p.map((n,i)=>{const j=n.getMonth()!==u.getMonth(),b=E(n,!0)===w,k=c(n),D=k?`${i%7===0||!c(p[i-1])?" band-start":""}${i%7===6||!p[i+1]||!c(p[i+1])?" band-end":""}`:"";return e.jsx("button",{className:`amx-mini-day${j?" out":""}${b?" today":""}${k?" band":""}${D}`,onClick:()=>M(n),title:o?s("calcfg.jumpToDay"):void 0,children:n.getDate()},+n)})})]})}function Pa(){const{t:s}=H(),o=ca(a=>a.vaultRoot)??"",f=pa(),g=xa(),N=ba(),x=ja(),u=v(a=>a.errors),d=y(a=>a.byVault),C=y(a=>a.setColor),p=y(a=>a.toggleHidden),w=y(a=>a.setDefault),c=y(a=>a.addMember),M=y(a=>a.removeMember),[n,i]=m.useState(!1),[j,b]=m.useState(null),[k,D]=m.useState(null),[t,h]=m.useState(null),[z,q]=m.useState(null);m.useEffect(()=>{if(!t&&!j)return;const a=l=>{l.key==="Escape"&&(l.stopPropagation(),h(null),b(null))};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[t,j]);const Y=m.useMemo(()=>new Set(f.map(a=>a.db.path)),[f]),L=[...f.map(a=>({db:a.db})),...g.map(a=>({db:a,readonly:!0,kind:"agent"})),...N.map(a=>({db:a,readonly:!0,kind:"other"})),...x.map(a=>({db:a,readonly:!0,kind:"ics"}))],O=va(o,d),J=a=>{h(null),F(s("calcfg.renameCalendar"),a.name).then(l=>{const r=l?.trim();r&&r!==a.name&&qa.getState().mutate(a.path,A=>({...A,name:r}))})},S=a=>a.slice(6),R=a=>u[S(a)],X=()=>{F(s("calcfg.subscribeExternal"),"",{label:s("calcfg.subscribeHint")}).then(a=>{const l=a?.trim();l&&v.getState().add(l)})},K=()=>{const a=document.createElement("input");a.type="file",a.accept=".ics,text/calendar",a.onchange=()=>{const l=a.files?.[0];if(l){if(l.size>U){D(s("calcfg.fileTooLarge",{mb:U/1024/1024}));return}D(null),l.text().then(r=>{v.getState().importText(Ma(r)||l.name.replace(/\.ics$/i,""),r)||D(s("calcfg.notIcs"))}).catch(r=>D(s("calcfg.readFailed",{msg:r?.message||String(r)})))}},a.click()},Q=a=>{const l=a.currentTarget.getBoundingClientRect();b({x:Math.max(12,Math.min(l.left,window.innerWidth-200)),y:l.bottom+4})};return e.jsxs("div",{className:"amx-calcfg",children:[e.jsxs("div",{className:"amx-calcfg-head",children:[e.jsx("span",{children:s("calcfg.title")}),e.jsx("button",{className:"amx-calcfg-addbtn","aria-label":s("calcfg.addCalendar"),title:s("calcfg.addCalendar"),onClick:Q,children:e.jsx(la,{size:14})})]}),L.length===0&&e.jsx("div",{className:"amx-calcfg-empty",children:s("calcfg.empty")}),e.jsx("div",{className:"amx-calcfg-list",children:L.map(({db:a,readonly:l,kind:r},A)=>{const $=Na(o,d,a.path,A),P=!Ca(o,d,a.path),Z=!l&&(O?O===a.path:A===0);return e.jsxs("div",{className:"amx-calcfg-row",children:[e.jsx("button",{className:`amx-calcfg-swatch${P?" on":""}`,style:{"--amx-swatch":$},role:"checkbox","aria-checked":P,"aria-label":s("calcfg.showName",{name:a.name}),onClick:()=>p(o,a.path)}),e.jsxs("span",{className:`amx-calcfg-name${P?"":" off"}`,title:R(a.path)||a.name,children:[a.name,r==="ics"&&R(a.path)&&e.jsxs("span",{className:"amx-calcfg-err",children:[" · ",s("calcfg.fetchFailed")]})]}),Z&&e.jsx("span",{className:"amx-calcfg-default",title:s("calcfg.defaultHint"),children:s("calcfg.default")}),e.jsx("button",{className:"amx-calcfg-more",title:s("calcfg.more"),"aria-label":s("calcfg.more"),onClick:aa=>{const B=aa.currentTarget.getBoundingClientRect();h({db:a,kind:r,color:$,x:Math.min(B.left,window.innerWidth-200),y:B.bottom+4})},children:"⋯"})]},a.path)})}),k&&e.jsx("div",{className:"amx-calcfg-hint",style:{color:"var(--danger)"},children:k}),j&&e.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>b(null),children:e.jsxs(G,{className:"amx-db-pop amx-calcfg-addmenu",x:j.x,y:j.y,onMouseDown:a=>a.stopPropagation(),children:[e.jsxs("button",{className:"amx-db-opt",onClick:()=>{b(null),i(!0)},children:[e.jsx(V,{size:14})," ",s("calcfg.addDatabase")]}),e.jsxs("button",{className:"amx-db-opt",onClick:()=>{b(null),X()},children:[e.jsx(wa,{size:14})," ",s("calcfg.subscribeExternal")]}),e.jsxs("button",{className:"amx-db-opt",onClick:()=>{b(null),K()},children:[e.jsx(Aa,{size:14})," ",s("calcfg.importIcs")]})]})}),t&&e.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>h(null),children:e.jsxs(G,{className:"amx-db-pop amx-calcfg-menu",x:t.x,y:t.y,onMouseDown:a=>a.stopPropagation(),children:[t.kind&&e.jsx("div",{className:"amx-calcfg-menusrc",children:t.kind==="agent"?s("calcfg.srcAgent"):t.kind==="other"?s("calcfg.srcOther",{side:t.db.vaultLabel||""}):s("calcfg.srcIcs")}),e.jsxs("label",{className:"amx-db-opt amx-calcfg-colorrow",children:[e.jsx("span",{className:"amx-calcfg-colordot",style:{background:t.color}}),s("calcfg.eventColor"),e.jsx("input",{type:"color",value:t.color,onChange:a=>{C(o,t.db.path,a.target.value),h({...t,color:a.target.value})}})]}),t.kind==="agent"||t.kind==="other"?null:t.kind==="ics"?e.jsxs(e.Fragment,{children:[!!v.getState().subs.find(a=>a.id===S(t.db.path))?.url&&e.jsx("button",{className:"amx-db-opt",onClick:()=>{v.getState().refresh(S(t.db.path)),h(null)},children:s("calcfg.refreshNow")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{const a=S(t.db.path),l=t.db.name;h(null),F(s("calcfg.renameSub"),l).then(r=>{r?.trim()&&v.getState().rename(a,r.trim())})},children:s("calcfg.rename")}),e.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{v.getState().remove(S(t.db.path)),h(null)},children:s("calcfg.unsubscribe")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"amx-db-opt",onClick:()=>J(t.db),children:s("calcfg.rename")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{w(o,t.db.path),h(null)},children:s("calcfg.setDefaultDb")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{Da(t.db.path),h(null)},children:s("calcfg.openInNewTab")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{q(t.db),h(null)},children:s("calcfg.columnMapping")}),e.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{M(o,t.db.path),h(null)},children:s("calcfg.removeFromCalendar")})]})]})}),n&&e.jsx(Fa,{memberPaths:Y,onClose:()=>i(!1),onAdd:(a,l,r)=>{c(o,a.path,l,r),i(!1)}}),z&&e.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>q(null),children:e.jsx("div",{className:"amx-db-pop amx-calpick-pop",onMouseDown:a=>a.stopPropagation(),children:e.jsx(W,{dbName:z.name,columns:z.columns,initial:ya(o,d,z.path),onCancel:()=>q(null),onConfirm:(a,l)=>{c(o,z.path,a,l),q(null)}})})})]})}function Fa({memberPaths:s,onClose:o,onAdd:f}){const{t:g}=H(),N=ka(),[x,u]=m.useState(""),[d,C]=m.useState(null),p=m.useMemo(()=>N.filter(c=>!s.has(c.path)&&c.columns.some(za)),[N,s]),w=x?p.filter(c=>c.name.toLowerCase().includes(x.toLowerCase())):p;return e.jsx("div",{className:"amx-qf-scrim",onMouseDown:o,children:d?e.jsx("div",{className:"amx-qf-card",onMouseDown:c=>c.stopPropagation(),children:e.jsx(W,{dbName:d.name,columns:d.columns,onCancel:()=>C(null),onConfirm:(c,M)=>f(d,c,M)})}):e.jsxs("div",{className:"amx-qf",onMouseDown:c=>c.stopPropagation(),children:[e.jsxs("div",{className:"amx-qf-head",children:[e.jsx(Sa,{size:16,className:"amx-qf-searchicon"}),e.jsx("input",{autoFocus:!0,className:"amx-qf-input",placeholder:g("calcfg.searchDbPlaceholder"),value:x,onChange:c=>u(c.target.value)})]}),e.jsxs("div",{className:"amx-qf-list",children:[w.map(c=>e.jsxs("button",{className:"amx-qf-row",onClick:()=>C(c),children:[e.jsx("span",{className:"amx-qf-icon",children:e.jsx(V,{size:15})}),e.jsx("span",{className:"amx-qf-title",children:c.name||c.path}),e.jsx("span",{className:"amx-qf-sub",children:c.path.replace(/\\/g,"/").split("/").slice(0,-1).join("/")||"/"})]},c.path)),w.length===0&&e.jsx("div",{className:"amx-qf-empty",children:g("calcfg.noCandidates")})]}),e.jsx("div",{className:"amx-qf-foot",children:g("calcfg.footHint")})]})})}export{Wa as CalendarConfigView};
1
+ import{j as e,u as O,r as m,a as ea}from"./index-YuejkHoJ.js";import{l as sa,aH as na,aA as ta,u as ca,a6 as la,X as G,D as _}from"./pageStore-D_fKLv-o.js";import"./client-DD5czSuF.js";import{A as oa}from"./astryxBridge-B2IZdPvo.js";import{pY as ra,eI as W,pZ as ia,p$ as da,pM as ma,qv as ua,qa as E,qe as ha,pW as fa,q0 as pa,pF as ga,pO as xa,pP as ba,pQ as ja,qw as v,pG as y,pH as va,pJ as Na,q4 as Ca,G as wa,e_ as F,ex as Da,qx as J,qy as ya,qz as Y,qA as Ma,qB as ka,ko as za,S as Sa}from"./appStore-BskcSDl6.js";import{u as qa}from"./dbStore-Bc2lC8ZI.js";import{u as I}from"./calendarNavStore-FKStA7Hh.js";import{U as Aa}from"./upload-VtCrluEO.js";import"./react-DOzedx9n.js";import"./ipc-8cxXGSZK.js";import"./nativeDownload-DlnT8U-y.js";import"./drawingStore-BD5m2eqn.js";ea({"calcfg.prevMonth":{zh:"上个月",en:"Previous month"},"calcfg.nextMonth":{zh:"下个月",en:"Next month"},"calcfg.jumpToDay":{zh:"跳转到这一天",en:"Jump to this day"},"calcfg.title":{zh:"日历",en:"Calendars"},"calcfg.empty":{zh:"还没有加入日历的多维表。",en:"No databases added to the calendar yet."},"calcfg.eventColor":{zh:"事件颜色",en:"Event color"},"calcfg.fetchFailed":{zh:"拉取失败",en:"Fetch failed"},"calcfg.default":{zh:"默认",en:"Default"},"calcfg.defaultHint":{zh:"新建的事件落在这里",en:"New events go here"},"calcfg.showName":{zh:"在日历中显示「{name}」",en:"Show “{name}” in the calendar"},"calcfg.srcAgent":{zh:"Agent 日程(只读)",en:"Agent schedule (read-only)"},"calcfg.srcOther":{zh:"{side} 的日历(只读)",en:"Calendar from {side} (read-only)"},"calcfg.srcIcs":{zh:"外部日历(只读)",en:"External calendar (read-only)"},"calcfg.more":{zh:"更多",en:"More"},"calcfg.addCalendar":{zh:"添加日历",en:"Add calendar"},"calcfg.addDatabase":{zh:"添加多维表",en:"Add database"},"calcfg.subscribeExternal":{zh:"订阅外部日历",en:"Subscribe to external calendar"},"calcfg.subscribeHint":{zh:"粘贴 .ics 订阅地址(Google / Outlook / Apple 日历「密钥地址」都行)",en:"Paste an .ics subscription URL (Google, Outlook, or Apple Calendar's private address all work)"},"calcfg.importIcs":{zh:"导入 .ics 文件",en:"Import .ics file"},"calcfg.fileTooLarge":{zh:"文件过大(> {mb}MB)",en:"File too large (over {mb} MB)"},"calcfg.notIcs":{zh:"这不是一个 .ics 日历文件",en:"That isn't an .ics calendar file"},"calcfg.readFailed":{zh:"读取失败:{msg}",en:"Failed to read: {msg}"},"calcfg.renameCalendar":{zh:"重命名日历",en:"Rename calendar"},"calcfg.renameSub":{zh:"重命名订阅",en:"Rename subscription"},"calcfg.rename":{zh:"重命名",en:"Rename"},"calcfg.refreshNow":{zh:"立即刷新",en:"Refresh now"},"calcfg.unsubscribe":{zh:"取消订阅",en:"Unsubscribe"},"calcfg.setDefaultDb":{zh:"设为默认日历",en:"Set as default calendar"},"calcfg.openInNewTab":{zh:"在新标签打开",en:"Open in new tab"},"calcfg.columnMapping":{zh:"日期与完成列…",en:"Date and done columns…"},"calcfg.removeFromCalendar":{zh:"从日历移除",en:"Remove from calendar"},"calcfg.searchDbPlaceholder":{zh:"搜索要加入日历的多维表…",en:"Search databases to add to the calendar…"},"calcfg.noCandidates":{zh:"没有含日期属性的可添加多维表",en:"No databases with a date property available to add"},"calcfg.footHint":{zh:"只有含「日期」属性的多维表会出现在这里",en:"Only databases with a Date property appear here"}});function Ja(){return e.jsx(oa,{children:e.jsxs("div",{className:"amx-calside",children:[e.jsx(Ea,{}),e.jsx(Pa,{})]})})}const T=s=>new Date(s.getFullYear(),s.getMonth(),1);function Ea(){const{t:s}=O(),o=sa(n=>(n.mainTabs,((n.api?na(n.api):null)?.params??{}).__type==="calendar")),f=I(n=>n.visibleStart),p=I(n=>n.visibleEnd),N=I(n=>n.requestJump),x=m.useMemo(()=>ra(new Date),[]),[u,d]=m.useState(()=>T(x));m.useEffect(()=>{if(o&&f&&p){const n=W(f),i=ia(n,Math.floor(da(W(p),n)/2));d(T(i))}},[o,f,p]);const C=ma(),g=m.useMemo(()=>ua(u),[u,C]),w=E(x,!0),c=n=>{if(!o||!f||!p)return!1;const i=E(n,!0);return i>=f&&i<=p},M=n=>{d(T(n)),o&&N(E(n,!0))};return e.jsxs("div",{className:"amx-mini",children:[e.jsxs("div",{className:"amx-mini-head",children:[e.jsx("span",{className:"amx-mini-title",children:ha(u)}),e.jsx("button",{className:"amx-mini-nav",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()-1,1)),"aria-label":s("calcfg.prevMonth"),children:e.jsx(fa,{size:14})}),e.jsx("button",{className:"amx-mini-nav",onClick:()=>d(new Date(u.getFullYear(),u.getMonth()+1,1)),"aria-label":s("calcfg.nextMonth"),children:e.jsx(ta,{size:14})})]}),e.jsx("div",{className:"amx-mini-dow",children:pa().map(n=>e.jsx("span",{children:n},n))}),e.jsx("div",{className:"amx-mini-grid",children:g.map((n,i)=>{const j=n.getMonth()!==u.getMonth(),b=E(n,!0)===w,k=c(n),D=k?`${i%7===0||!c(g[i-1])?" band-start":""}${i%7===6||!g[i+1]||!c(g[i+1])?" band-end":""}`:"";return e.jsx("button",{className:`amx-mini-day${j?" out":""}${b?" today":""}${k?" band":""}${D}`,onClick:()=>M(n),title:o?s("calcfg.jumpToDay"):void 0,children:n.getDate()},+n)})})]})}function Pa(){const{t:s}=O(),o=ca(a=>a.vaultRoot)??"",f=ga(),p=xa(),N=ba(),x=ja(),u=v(a=>a.errors),d=y(a=>a.byVault),C=y(a=>a.setColor),g=y(a=>a.toggleHidden),w=y(a=>a.setDefault),c=y(a=>a.addMember),M=y(a=>a.removeMember),[n,i]=m.useState(!1),[j,b]=m.useState(null),[k,D]=m.useState(null),[t,h]=m.useState(null),[z,q]=m.useState(null);m.useEffect(()=>{if(!t&&!j)return;const a=l=>{l.key==="Escape"&&(l.stopPropagation(),h(null),b(null))};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[t,j]);const U=m.useMemo(()=>new Set(f.map(a=>a.db.path)),[f]),L=[...f.map(a=>({db:a.db})),...p.map(a=>({db:a,readonly:!0,kind:"agent"})),...N.map(a=>({db:a,readonly:!0,kind:"other"})),...x.map(a=>({db:a,readonly:!0,kind:"ics"}))],R=va(o,d),V=a=>{h(null),F(s("calcfg.renameCalendar"),a.name).then(l=>{const r=l?.trim();r&&r!==a.name&&qa.getState().mutate(a.path,A=>({...A,name:r}))})},S=a=>a.slice(6),H=a=>u[S(a)],Q=()=>{F(s("calcfg.subscribeExternal"),"",{label:s("calcfg.subscribeHint")}).then(a=>{const l=a?.trim();l&&v.getState().add(l)})},X=()=>{const a=document.createElement("input");a.type="file",a.accept=".ics,text/calendar",a.onchange=()=>{const l=a.files?.[0];if(l){if(l.size>Y){D(s("calcfg.fileTooLarge",{mb:Y/1024/1024}));return}D(null),l.text().then(r=>{v.getState().importText(Ma(r)||l.name.replace(/\.ics$/i,""),r)||D(s("calcfg.notIcs"))}).catch(r=>D(s("calcfg.readFailed",{msg:r?.message||String(r)})))}},a.click()},K=a=>{const l=a.currentTarget.getBoundingClientRect();b({x:Math.max(12,Math.min(l.left,window.innerWidth-200)),y:l.bottom+4})};return e.jsxs("div",{className:"amx-calcfg",children:[e.jsxs("div",{className:"amx-calcfg-head",children:[e.jsx("span",{children:s("calcfg.title")}),e.jsx("button",{className:"amx-calcfg-addbtn","aria-label":s("calcfg.addCalendar"),title:s("calcfg.addCalendar"),onClick:K,children:e.jsx(la,{size:14})})]}),L.length===0&&e.jsx("div",{className:"amx-calcfg-empty",children:s("calcfg.empty")}),e.jsx("div",{className:"amx-calcfg-list",children:L.map(({db:a,readonly:l,kind:r},A)=>{const $=Na(o,d,a.path,A),P=!Ca(o,d,a.path),Z=!l&&(R?R===a.path:A===0);return e.jsxs("div",{className:"amx-calcfg-row",children:[e.jsx("button",{className:`amx-calcfg-swatch${P?" on":""}`,style:{"--amx-swatch":$},role:"checkbox","aria-checked":P,"aria-label":s("calcfg.showName",{name:a.name}),onClick:()=>g(o,a.path)}),e.jsxs("span",{className:`amx-calcfg-name${P?"":" off"}`,title:H(a.path)||a.name,children:[a.name,r==="ics"&&H(a.path)&&e.jsxs("span",{className:"amx-calcfg-err",children:[" · ",s("calcfg.fetchFailed")]})]}),Z&&e.jsx("span",{className:"amx-calcfg-default",title:s("calcfg.defaultHint"),children:s("calcfg.default")}),e.jsx("button",{className:"amx-calcfg-more",title:s("calcfg.more"),"aria-label":s("calcfg.more"),onClick:aa=>{const B=aa.currentTarget.getBoundingClientRect();h({db:a,kind:r,color:$,x:Math.min(B.left,window.innerWidth-200),y:B.bottom+4})},children:"⋯"})]},a.path)})}),k&&e.jsx("div",{className:"amx-calcfg-hint",style:{color:"var(--danger)"},children:k}),j&&e.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>b(null),children:e.jsxs(G,{className:"amx-db-pop amx-calcfg-addmenu",x:j.x,y:j.y,onMouseDown:a=>a.stopPropagation(),children:[e.jsxs("button",{className:"amx-db-opt",onClick:()=>{b(null),i(!0)},children:[e.jsx(_,{size:14})," ",s("calcfg.addDatabase")]}),e.jsxs("button",{className:"amx-db-opt",onClick:()=>{b(null),Q()},children:[e.jsx(wa,{size:14})," ",s("calcfg.subscribeExternal")]}),e.jsxs("button",{className:"amx-db-opt",onClick:()=>{b(null),X()},children:[e.jsx(Aa,{size:14})," ",s("calcfg.importIcs")]})]})}),t&&e.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>h(null),children:e.jsxs(G,{className:"amx-db-pop amx-calcfg-menu",x:t.x,y:t.y,onMouseDown:a=>a.stopPropagation(),children:[t.kind&&e.jsx("div",{className:"amx-calcfg-menusrc",children:t.kind==="agent"?s("calcfg.srcAgent"):t.kind==="other"?s("calcfg.srcOther",{side:t.db.vaultLabel||""}):s("calcfg.srcIcs")}),e.jsxs("label",{className:"amx-db-opt amx-calcfg-colorrow",children:[e.jsx("span",{className:"amx-calcfg-colordot",style:{background:t.color}}),s("calcfg.eventColor"),e.jsx("input",{type:"color",value:t.color,onChange:a=>{C(o,t.db.path,a.target.value),h({...t,color:a.target.value})}})]}),t.kind==="agent"||t.kind==="other"?null:t.kind==="ics"?e.jsxs(e.Fragment,{children:[!!v.getState().subs.find(a=>a.id===S(t.db.path))?.url&&e.jsx("button",{className:"amx-db-opt",onClick:()=>{v.getState().refresh(S(t.db.path)),h(null)},children:s("calcfg.refreshNow")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{const a=S(t.db.path),l=t.db.name;h(null),F(s("calcfg.renameSub"),l).then(r=>{r?.trim()&&v.getState().rename(a,r.trim())})},children:s("calcfg.rename")}),e.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{v.getState().remove(S(t.db.path)),h(null)},children:s("calcfg.unsubscribe")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"amx-db-opt",onClick:()=>V(t.db),children:s("calcfg.rename")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{w(o,t.db.path),h(null)},children:s("calcfg.setDefaultDb")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{Da(t.db.path),h(null)},children:s("calcfg.openInNewTab")}),e.jsx("button",{className:"amx-db-opt",onClick:()=>{q(t.db),h(null)},children:s("calcfg.columnMapping")}),e.jsx("button",{className:"amx-db-opt amx-db-opt-danger",onClick:()=>{M(o,t.db.path),h(null)},children:s("calcfg.removeFromCalendar")})]})]})}),n&&e.jsx(Fa,{memberPaths:U,onClose:()=>i(!1),onAdd:(a,l,r)=>{c(o,a.path,l,r),i(!1)}}),z&&e.jsx("div",{className:"amx-db-popwrap",onMouseDown:()=>q(null),children:e.jsx("div",{className:"amx-db-pop amx-calpick-pop",onMouseDown:a=>a.stopPropagation(),children:e.jsx(J,{dbName:z.name,columns:z.columns,initial:ya(o,d,z.path),onCancel:()=>q(null),onConfirm:(a,l)=>{c(o,z.path,a,l),q(null)}})})})]})}function Fa({memberPaths:s,onClose:o,onAdd:f}){const{t:p}=O(),N=ka(),[x,u]=m.useState(""),[d,C]=m.useState(null),g=m.useMemo(()=>N.filter(c=>!s.has(c.path)&&c.columns.some(za)),[N,s]),w=x?g.filter(c=>c.name.toLowerCase().includes(x.toLowerCase())):g;return e.jsx("div",{className:"amx-qf-scrim",onMouseDown:o,children:d?e.jsx("div",{className:"amx-qf-card",onMouseDown:c=>c.stopPropagation(),children:e.jsx(J,{dbName:d.name,columns:d.columns,onCancel:()=>C(null),onConfirm:(c,M)=>f(d,c,M)})}):e.jsxs("div",{className:"amx-qf",onMouseDown:c=>c.stopPropagation(),children:[e.jsxs("div",{className:"amx-qf-head",children:[e.jsx(Sa,{size:16,className:"amx-qf-searchicon"}),e.jsx("input",{autoFocus:!0,className:"amx-qf-input",placeholder:p("calcfg.searchDbPlaceholder"),value:x,onChange:c=>u(c.target.value)})]}),e.jsxs("div",{className:"amx-qf-list",children:[w.map(c=>e.jsxs("button",{className:"amx-qf-row",onClick:()=>C(c),children:[e.jsx("span",{className:"amx-qf-icon",children:e.jsx(_,{size:15})}),e.jsx("span",{className:"amx-qf-title",children:c.name||c.path}),e.jsx("span",{className:"amx-qf-sub",children:c.path.replace(/\\/g,"/").split("/").slice(0,-1).join("/")||"/"})]},c.path)),w.length===0&&e.jsx("div",{className:"amx-qf-empty",children:p("calcfg.noCandidates")})]}),e.jsx("div",{className:"amx-qf-foot",children:p("calcfg.footHint")})]})})}export{Ja as CalendarConfigView};
@@ -0,0 +1 @@
1
+ import{r as e,j as i}from"./index-YuejkHoJ.js";import{TodoListView as s}from"./TodoListView-BsPt2GUU.js";import{u as o}from"./calendarNavStore-FKStA7Hh.js";import"./astryxBridge-B2IZdPvo.js";import"./appStore-BskcSDl6.js";import"./dbStore-Bc2lC8ZI.js";import"./pageStore-D_fKLv-o.js";import"./react-DOzedx9n.js";import"./client-DD5czSuF.js";import"./ipc-8cxXGSZK.js";import"./nativeDownload-DlnT8U-y.js";import"./drawingStore-BD5m2eqn.js";import"./draft-DTzuTatQ.js";import"./EventCard-D9uQe7g4.js";import"./chevron-up-C_EDOZzI.js";import"./Tooltip-CuXpWtdJ.js";function g(){const r=o(m=>m.setSideEl),t=e.useRef(null);return e.useEffect(()=>(r(t.current),()=>{o.getState().sideEl===t.current&&r(null)}),[r]),i.jsx("div",{className:"amx-calside2",ref:t,children:i.jsx(s,{params:{side:!0}})})}export{g as CalendarSide};